ilml-plugin-linkedin 1.14.3 → 1.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/connect.mjs +19 -19
- package/dist/enrichProfile.mjs +3 -3
- package/dist/enrichProfiles.mjs +30 -30
- package/dist/funnelRunner.mjs +10 -10
- package/dist/run.mjs +18 -18
- package/dist/syncAll.mjs +1 -1
- package/dist/version.mjs +1 -1
- package/ilml-plugin.json +1 -1
- package/package.json +1 -1
package/dist/syncAll.mjs
CHANGED
|
@@ -235,7 +235,7 @@ function findEntryContainer(root) {
|
|
|
235
235
|
candidates.sort((a, b) => b.count - a.count || b.totalText - a.totalText);
|
|
236
236
|
return candidates[0]?.el;
|
|
237
237
|
}
|
|
238
|
-
`});var go={};Ue(go,{clickConnectButton:()=>Qt,default:()=>Pr,detectConnectionStatus:()=>xe,findConnectButton:()=>rt,runFunnel:()=>po,sendConnectionRequest:()=>Xt,shouldExcludeLocation:()=>ht,viewProfile:()=>Kt});async function mo(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}function ht(e,t=[]){if(!e||!t||t.length===0)return!1;let n=e.toLowerCase();return t.some(o=>n.includes(o.toLowerCase()))}async function Kt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:s=!1,extractEducation:i=!1,extractSkills:a=!1,extractRecommendations:l=!1,extractCertifications:r=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),await he(e)&&(console.log(" Dismissed Premium overlay"),await $(1500),await mo(e,t));let c=0;for(let g=0;g<2;g++){let h=await e.evaluate(()=>document.body.scrollHeight);for(let C=1;C<=6;C++)await e.evaluate(_=>window.scrollTo(0,_),h*C/6),await $(900);let k=await e.evaluate(()=>document.body.scrollHeight);if(k===c)break;c=k}await $(800);let f=await e.evaluate(()=>{let g=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Licenses & certifications","Courses","Test scores","Organizations"]),h=new Set(["Ad Options","Don\u2019t want to see this","0 notifications","Explore Premium profiles","You might like","People you may know","Suggested for you","More profiles for you","Promoted"]),k=R=>{let D=(R||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(D)},C={name:null,title:null,location:null,currentCompany:null,currentSchool:null,connectionDegree:null,hasVerifiedBadge:!1,photoUrl:null,connectionsLevel:null,mutualConnectionsCount:null,followers:null,openToWork:!1,hiring:!1,about:null,topSkills:null,availableSections:[]},_=document.querySelector("main");if(!_)return C;let I=[...Array.from(_.querySelectorAll("h1")),...Array.from(_.querySelectorAll("h2"))],T=Array.from(_.querySelectorAll("h2")),L=I.find(R=>{let D=R.textContent&&R.textContent.trim(),O=(D||"").replace(/\s*\(\d+\)$/,"").trim();return D&&D.length>1&&D.length<100&&!g.has(O)&&!h.has(O)}),G=L?L.textContent.trim():null,v=L?L.parentElement:null;for(;v&&v!==_&&!Array.from(v.children).filter(D=>D.tagName==="P").some(D=>{let O=D.textContent&&D.textContent.trim();return O&&O.length>5&&!k(O)});)v=v.parentElement;let x=null,A=null,M=null,q=null;if(v&&v!==_){let R=Array.from(v.children).filter(O=>O.tagName==="P").filter(O=>{let de=O.textContent&&O.textContent.trim();return de&&de.length>5&&!k(de)});if(R[0]&&(x=R[0].textContent.trim()),R[1]){let O=R[1].textContent.trim().split(/\s*[·•]\s*/);A=O[0]||null,O.length>1&&(M=O.slice(1).join(" \xB7 "))}let D=Array.from(v.children).filter(O=>O.tagName==="DIV");for(let O=D.length-1;O>=0;O--){let de=D[O].textContent&&D[O].textContent.trim();if(de&&!(G&&de.startsWith(G))&&(q=de.split(/[·•]/)[0].trim(),q))break}}let re=null;if(v){let R=v.querySelectorAll("p, span, div");for(let D of R){let O=(D.textContent||"").trim().replace(/^[·•]\s*/,"");if(O==="1st"||O==="2nd"||O==="3rd"){re=O;break}}}let ie=!!_.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),j=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),F=j&&j.src||null,P=_.textContent||"",H=null,oe=P.match(/(\d+\+?)\s+connections\b/i);oe&&(H=oe[1]+" connections");let at=null,sn=P.match(/(\d+)\s+mutual connection/i),rn=P.match(/and\s+(\d+)\s+other mutual/i),Co=P.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);sn?at=parseInt(sn[1],10):rn?at=2+parseInt(rn[1],10):Co&&(at=2);let an=null,ln=null,cn=T.find(R=>R.textContent&&R.textContent.trim()==="About");if(cn){let R=cn.parentElement;for(;R&&R.tagName!=="SECTION";)R=R.parentElement;if(R){let D=(R.textContent||"").trim();D=D.replace(/^About\s*/,"").trim();let O=D.match(/Top skills\s*(.+?)$/i);if(O){let wt=O[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Ao=>Ao.trim()).filter(Boolean);wt.length>0&&wt.length<10&&(ln=wt)}D=D.split(/\n?…\s*more/i)[0].trim(),D=D.split(/\n?\.\.\.\s*more/i)[0].trim(),D=D.split(/\bTop skills\b/i)[0].trim(),D=D.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),an=D||null}}let un=null,dn=T.find(R=>R.textContent&&R.textContent.trim()==="Activity");if(dn){let R=dn.parentElement;for(;R&&R.tagName!=="SECTION";)R=R.parentElement;if(R){let D=(R.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);D&&(un=parseInt(D[1].replace(/,/g,""),10))}}let Eo=[...new Set(T.map(R=>(R.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(R=>R&&R.length>1&&R.length<60&&R!==G).filter(R=>g.has(R)))],Le=document.body.textContent||"",xo=/#OpenToWork\b/i.test(Le)||/\bOpen to work\b/.test(Le),_o=/#Hiring\b/i.test(Le)||/\bI'?m hiring\b/i.test(Le)||/\bWe are hiring\b/i.test(Le);return{name:G,title:x,location:q,currentCompany:A,currentSchool:M,connectionDegree:re,hasVerifiedBadge:ie,photoUrl:F,connectionsLevel:H,mutualConnectionsCount:at,followers:un,openToWork:xo,hiring:_o,about:an,topSkills:ln,availableSections:Eo}});console.log(`Viewed: ${f.name} - ${f.title}`);let d=null,m=null,y=null,p=null,S=null,w=null;if(o||s||i||a||l||r){let g=await Promise.resolve().then(()=>(fo(),uo));o&&(d=await g.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),s&&(m=await g.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${m.length} entries`)),i&&(y=await g.extractEducationFromDetails(e,t),console.log(` + Education: ${y.length} entries`)),a&&(p=await g.extractSkillsFromDetails(e,t),console.log(` + Skills: ${p.length} entries`)),l&&(S=await g.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${S.length} entries`)),r&&(w=await g.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${w.length} entries`))}return{...f,profileUrl:t,...d!==null&&{experience:d},...m!==null&&{featured:m},...y!==null&&{education:y},...p!==null&&{skillsFull:p},...S!==null&&{recommendations:S},...w!==null&&{certifications:w}}}catch(u){console.error(`Error viewing profile ${t}:`,u.message);try{await e.goto("about:blank",{timeout:1e4}),await $(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(u.message||""))throw u;return null}}async function xe(e){let t=await e.evaluate(()=>{let n=document.querySelectorAll('button[aria-label*="Pending"]'),o=Array.from(n).map(r=>r.getAttribute("aria-label")),s=document.querySelector('button[aria-label*="Message"]'),i=document.querySelector('button[aria-label*="Invite"][aria-label*="connect"]')||document.querySelector('button[aria-label="Connect"]'),a={pendingCount:n.length,pendingLabels:o,hasMessageBtn:!!s,hasConnectBtn:!!i};return n.length>0?{status:"pending",debug:a}:s&&!i?{status:"connected",debug:a}:document.body.innerText.includes("1st degree connection")?{status:"connected",debug:a}:{status:"not_connected",debug:a}});return console.log(" DEBUG connection status:",JSON.stringify(t.debug)),t.status}async function rt(e){let t=null,n=await e.evaluate(()=>{let r=document.querySelector("h1")?.textContent?.trim();if(r&&!r.includes("notification"))return r;let u=document.querySelector('main h2, [class*="profile"] h2, [class*="top-card"] h2');if(u&&(r=u.textContent?.trim(),r&&!r.includes("notification")))return r;let c=document.querySelector('[class*="text-heading-xlarge"]')||document.querySelector('[class*="profile-card-title"]')||document.querySelector(".pv-text-details__left-panel h1");if(c)return c.textContent?.trim()||"";let f=document.title;return f&&f.includes("|")?f.split("|")[0].trim():""});if(console.log(` Profile name: "${n}"`),n){let r=await e.evaluate(()=>{let c=document.querySelectorAll('a[href*="custom-invite"]');return{count:c.length,labels:Array.from(c).map(f=>f.getAttribute("aria-label")?.slice(0,50))}});r.count>0&&console.log(` S0: ${r.count} custom-invite links: ${JSON.stringify(r.labels)}`),t=await e.evaluateHandle(c=>{let f=document.querySelectorAll('a[href*="custom-invite"]'),d=c.toLowerCase().split(" ")[0],m='[class*="pymk"], [class*="people-also-viewed"], [class*="browse-map"], [class*="discover"], [class*="similar"], aside';for(let y of f){let p=y.getBoundingClientRect();if(p.width===0||p.height===0||y.closest(m))continue;if((y.getAttribute("aria-label")||"").toLowerCase().includes(d))return y}return null},n);let u=t?.asElement?.()||null;if(u||await t?.dispose?.().catch(()=>{}),u)return console.log(" Found: Connect link (new LinkedIn 2025)"),{button:u,method:"connect_link"}}if(n){let r=n.split(" ")[0].toLowerCase();console.log(` Looking for button with name: "${r}"`);let u=await e.evaluate(f=>{let d=new RegExp("\\b"+f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","i"),m=document.querySelectorAll("button[aria-label]");return Array.from(m).filter(p=>{let S=p.getAttribute("aria-label")||"";return(S.toLowerCase().includes("invite")||S.toLowerCase().includes("connect"))&&d.test(S)}).map(p=>p.getAttribute("aria-label")?.slice(0,50))},r);u.length>0&&console.log(` S1: matched buttons: ${JSON.stringify(u)}`),t=await e.evaluateHandle(f=>{let d=document.querySelectorAll("button[aria-label]"),m=new RegExp("\\b"+f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","i");for(let y of d){let p=y.getAttribute("aria-label")||"";if((p.toLowerCase().includes("invite")||p.toLowerCase().includes("connect"))&&m.test(p))return y}return null},r);let c=t?.asElement?.()||null;if(c||await t?.dispose?.().catch(()=>{}),c)return console.log(" Found: button matching profile name"),{button:c,method:"name_matched_button"}}if(t=await e.$('button.artdeco-button--primary[aria-label*="Invite"]:not([class*="sticky-header"]):not([class*="muted"])'),t&&n){let r=await e.evaluate(c=>(c.getAttribute("aria-label")||"").toLowerCase(),t),u=n.split(" ")[0].toLowerCase();r.includes("invite")&&!r.includes(u)&&(console.log(` Skipping primary button: wrong person (${r})`),t=null)}if(t||(t=await e.$('button.artdeco-button--primary[aria-label="Connect"]:not([class*="sticky-header"]):not([class*="muted"])')),t)return console.log(" Found: primary button"),{button:t,method:"primary_button"};let o=await e.$$('button[aria-label*="Invite"][aria-label*="connect"]');o.length===0&&(o=await e.$$('button[aria-label="Connect"]'));let s=n?n.split(" ")[0].toLowerCase():"",i=null;for(let r of o){let u=await e.evaluate((c,f)=>{let d=c.className.includes("muted"),m=c.className.includes("sticky-header")||c.className.includes("sticky"),y=c.closest('[class*="pymk"], [class*="people-also-viewed"], [class*="browse-map"]')!==null,p=(c.getAttribute("aria-label")||"").toLowerCase(),S=p.includes("invite"),w=f?p.includes(f):!0;return{isMuted:d,isStickyHeader:m,inRecommendations:y,hasInvite:S,matchesName:w,ariaLabel:p}},r,s);if(!u.isMuted&&!u.isStickyHeader&&!u.inRecommendations){if(u.hasInvite&&!u.matchesName){console.log(` Skipping secondary button: wrong person (${u.ariaLabel})`);continue}i=r;break}}for(let r of o)r!==i&&await r.dispose().catch(()=>{});if(i)return console.log(" Found: secondary button"),{button:i,method:"secondary_button"};if(t=await e.$('section.pv-supplementary-action button[aria-label*="Invite"]'),t||(t=await e.$('section.pv-supplementary-action button[aria-label="Connect"]')),t)return console.log(" Found: supplementary section"),{button:t,method:"supplementary_section"};console.log(" Trying More actions dropdown...");let a=null,l=await e.$$('button[id*="profile-overflow-action"]');for(let r of l){let u=await e.evaluate(c=>{let f=c.getBoundingClientRect(),d=f.width>0&&f.height>0,m=c.closest('.sticky-header, [class*="sticky"]')!==null;return{isVisible:d,isInStickyHeader:m,top:f.top}},r);if(u.isVisible&&!u.isInStickyHeader){a=r,console.log(" Found More button by ID pattern (main)");break}}for(let r of l)r!==a&&await r.dispose().catch(()=>{});if(!a&&l.length>0&&(a=l[l.length-1],console.log(" Found More button by ID pattern (last)")),a||(a=await e.$('button[aria-label="More actions"]'),a&&console.log(" Found More button by aria-label")),!a){let r=await e.evaluateHandle(()=>{let c=Array.from(document.querySelectorAll("button, a")).find(d=>{let m=d.innerText?.trim(),y=d.getAttribute("aria-label")||"",p=d.getBoundingClientRect();return p.top<100||p.top>600||p.width===0?!1:m==="Follow"||m==="Message"||m==="Connect"||y.includes("Follow")||y.includes("Message")||y.includes("Invite")});if(!c)return null;let f=c.parentElement;for(let d=0;d<8&&f;d++){for(let m of f.querySelectorAll("button"))if(m.innerText?.trim()==="More"&&m!==c)return m;f=f.parentElement}return null});a=r?.asElement?.()||null,a||await r?.dispose?.().catch(()=>{}),a&&console.log(" Found More button by text (near profile actions)")}if(a)try{if(await e.evaluate(c=>c.scrollIntoView({behavior:"smooth",block:"center"}),a),await $(500),await e.evaluate(c=>c.click(),a),await $(2e3),!e.url().includes("/in/"))return console.log(" Redirect detected after More click, aborting"),null;let u=await e.$('.artdeco-dropdown__item[aria-label*="Invite"]');if(u||(u=await e.$('.artdeco-dropdown__item[aria-label*="connect"]')),u||(u=await e.$('.artdeco-dropdown__item[aria-label="Connect"]')),u||(u=await e.$('div[role="button"][aria-label*="Invite"]')),u||(u=await e.$('div[role="button"][aria-label*="connect"]')),!u){let c=await e.evaluateHandle(()=>{let f=document.querySelectorAll('[role="menu"], [popover], .artdeco-dropdown__content');for(let d of f){let m=d.querySelector('a[href*="custom-invite"]');if(m)return m;for(let y of d.querySelectorAll('a, div[role="menuitem"], div[role="button"]'))if(y.innerText?.trim()==="Connect")return y}return null});u=c?.asElement?.()||null,u||await c?.dispose?.().catch(()=>{})}if(!u){let c=await e.evaluate(()=>{let f=document.querySelectorAll('[role="menu"], [popover], .artdeco-dropdown__content'),d=[];for(let m of f)for(let y of m.querySelectorAll('[role="menuitem"], a, div')){let p=y.innerText?.trim();p&&p.length<40&&d.push(p)}return[...new Set(d)].slice(0,10)});console.log(` More dropdown items: ${JSON.stringify(c)}`)}if(u)return console.log(" Found: More dropdown"),{button:u,method:"more_dropdown"};await e.keyboard.press("Escape")}catch(r){console.log(" More dropdown click failed:",r.message),await e.keyboard.press("Escape")}if(t=await e.$('button[aria-label*="Invite"]'),t&&n){let r=await e.evaluate(c=>(c.getAttribute("aria-label")||"").toLowerCase(),t),u=n.split(" ")[0].toLowerCase();r.includes("invite")&&!r.includes(u)&&(console.log(` Skipping generic button: wrong person (${r})`),t=null)}return t||(t=await e.$('button[aria-label="Connect"]')),t?(console.log(" Found: generic button"),{button:t,method:"generic_button"}):null}async function Qt(e,t){await e.evaluate(c=>c.scrollIntoView({behavior:"smooth",block:"center"}),t),await $(500);let n=await e.evaluate(c=>({tag:c.tagName,ariaLabel:c.getAttribute("aria-label"),href:c.getAttribute("href")}),t),s=n.tag==="A"&&n.href&&n.href.includes("custom-invite"),i=n.tag==="DIV",a=(n.ariaLabel||"").toLowerCase();if(a.includes("invite")){let c=await e.evaluate(()=>((document.querySelector("main h1")||document.querySelector("h1")||document.querySelector("main h2"))?.textContent?.trim()||"").split(" ")[0].toLowerCase());if(c&&!a.includes(c))return console.log(` \u2717 Identity guard: control is for someone else ("${n.ariaLabel}") \u2014 refusing to click (target: ${c})`),"wrong_target"}if(s){console.log(" Clicking custom-invite link (will navigate)..."),await Promise.all([e.waitForNavigation({waitUntil:"domcontentloaded",timeout:3e4}).catch(()=>{}),e.evaluate(f=>f.click(),t)]),await $(2e3);let c=e.url();if(c.includes("premium")||c.includes("redeem"))return console.log(" \u26A0 LinkedIn redirected to Premium page - connection limit reached?"),await e.goBack(),await $(2e3),"premium_redirect"}else i?(await e.evaluate(c=>c.click(),t),await $(3e3)):(await e.evaluate(c=>c.click(),t),await $(3e3));let l=e.url();if(l.includes("/premium/")||l.includes("/redeem"))return console.log(" \u26A0 LinkedIn redirected to Premium upsell page"),"premium_redirect";let r=await e.evaluate(()=>!!document.querySelector('[role="dialog"], .artdeco-modal, .send-invite')),u=e.url();return console.log(r?` \u2713 Connect sent \u2014 ${u}`:` \u26A0 No modal after connect click \u2014 ${u}`),"success"}async function Nr(e){console.log(" Upsell: Premium required for notes");let t=await e.$('button[aria-label="Dismiss"]')||await e.$("button.artdeco-modal__dismiss");t?await t.click():await e.keyboard.press("Escape"),await $(1500);let n=await rt(e);if(n){await e.evaluate(s=>s.click(),n),await $(2e3);let o=await e.$('button[aria-label="Send without a note"]');if(o){try{await o.evaluate(s=>s.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (without note)"),!0}}return!1}async function Xt(e,t,n={}){let{source:o="unknown",skipQuotaGate:s=!1,skipQuotaRecord:i=!1}=n;if(!s){let l=Et();if(!l.allowed)return console.log(` \u26A0 Connection quota reached \u2014 not sending: ${l.reason}`),{success:!1,reason:"quota_exhausted",connectionSent:!1,withCustomMessage:!1,messageSent:null,method:null,error:l.reason,profileInfo:null}}let a=await jr(e,t,n);return a.connectionSent&&!i&&_n(t,o),a}async function jr(e,t,n={}){let{message:o=null,useCustomMessage:s=!0,skipIfPending:i=!0,skipIfConnected:a=!0,excludeLocations:l=[]}=n,r={success:!1,reason:null,connectionSent:!1,withCustomMessage:!1,messageSent:null,method:null,error:null,profileInfo:null};try{let u=t.split("/in/")[1]?.replace("/","")||"unknown";if(console.log(`
|
|
238
|
+
`});var go={};Ue(go,{clickConnectButton:()=>Qt,default:()=>Pr,detectConnectionStatus:()=>xe,findConnectButton:()=>rt,runFunnel:()=>po,sendConnectionRequest:()=>Xt,shouldExcludeLocation:()=>ht,viewProfile:()=>Kt});async function mo(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}function ht(e,t=[]){if(!e||!t||t.length===0)return!1;let n=e.toLowerCase();return t.some(o=>n.includes(o.toLowerCase()))}async function Kt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:s=!1,extractEducation:i=!1,extractSkills:a=!1,extractRecommendations:l=!1,extractCertifications:r=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),await he(e)&&(console.log(" Dismissed Premium overlay"),await $(1500),await mo(e,t));let c=0;for(let g=0;g<2;g++){let h=await e.evaluate(()=>document.body.scrollHeight);for(let C=1;C<=6;C++)await e.evaluate(_=>window.scrollTo(0,_),h*C/6),await $(900);let k=await e.evaluate(()=>document.body.scrollHeight);if(k===c)break;c=k}await $(800);let f=await e.evaluate(()=>{let g=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Licenses & certifications","Courses","Test scores","Organizations"]),h=new Set(["Ad Options","Don\u2019t want to see this","0 notifications","Explore Premium profiles","You might like","People you may know","Suggested for you","More profiles for you","Promoted"]),k=R=>{let D=(R||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(D)},C={name:null,title:null,location:null,currentCompany:null,currentSchool:null,connectionDegree:null,hasVerifiedBadge:!1,photoUrl:null,connectionsLevel:null,mutualConnectionsCount:null,followers:null,openToWork:!1,hiring:!1,about:null,topSkills:null,availableSections:[]},_=document.querySelector("main");if(!_)return C;let I=[...Array.from(_.querySelectorAll("h1")),...Array.from(_.querySelectorAll("h2"))],T=Array.from(_.querySelectorAll("h2")),L=I.find(R=>{let D=R.textContent&&R.textContent.trim(),O=(D||"").replace(/\s*\(\d+\)$/,"").trim();return D&&D.length>1&&D.length<100&&!g.has(O)&&!h.has(O)}),G=L?L.textContent.trim():null,v=L?L.parentElement:null;for(;v&&v!==_&&!Array.from(v.children).filter(D=>D.tagName==="P").some(D=>{let O=D.textContent&&D.textContent.trim();return O&&O.length>5&&!k(O)});)v=v.parentElement;let x=null,A=null,M=null,q=null;if(v&&v!==_){let R=Array.from(v.children).filter(O=>O.tagName==="P").filter(O=>{let de=O.textContent&&O.textContent.trim();return de&&de.length>5&&!k(de)});if(R[0]&&(x=R[0].textContent.trim()),R[1]){let O=R[1].textContent.trim().split(/\s*[·•]\s*/);A=O[0]||null,O.length>1&&(M=O.slice(1).join(" \xB7 "))}let D=Array.from(v.children).filter(O=>O.tagName==="DIV");for(let O=D.length-1;O>=0;O--){let de=D[O].textContent&&D[O].textContent.trim();if(de&&!(G&&de.startsWith(G))&&(q=de.split(/[·•]/)[0].trim(),q))break}}let re=null;if(v){let R=v.querySelectorAll("p, span, div");for(let D of R){let O=(D.textContent||"").trim().replace(/^[·•]\s*/,"");if(O==="1st"||O==="2nd"||O==="3rd"){re=O;break}}}let ie=!!_.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),j=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),F=j&&j.src||null,P=_.textContent||"",H=null,oe=P.match(/(\d+\+?)\s+connections\b/i);oe&&(H=oe[1]+" connections");let at=null,sn=P.match(/(\d+)\s+mutual connection/i),rn=P.match(/and\s+(\d+)\s+other mutual/i),Co=P.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);sn?at=parseInt(sn[1],10):rn?at=2+parseInt(rn[1],10):Co&&(at=2);let an=null,ln=null,cn=T.find(R=>R.textContent&&R.textContent.trim()==="About");if(cn){let R=cn.parentElement;for(;R&&R.tagName!=="SECTION";)R=R.parentElement;if(R){let D=(R.textContent||"").trim();D=D.replace(/^About\s*/,"").trim();let O=D.match(/Top skills\s*(.+?)$/i);if(O){let wt=O[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Ao=>Ao.trim()).filter(Boolean);wt.length>0&&wt.length<10&&(ln=wt)}D=D.split(/\n?…\s*more/i)[0].trim(),D=D.split(/\n?\.\.\.\s*more/i)[0].trim(),D=D.split(/\bTop skills\b/i)[0].trim(),D=D.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),an=D||null}}let un=null,dn=T.find(R=>R.textContent&&R.textContent.trim()==="Activity");if(dn){let R=dn.parentElement;for(;R&&R.tagName!=="SECTION";)R=R.parentElement;if(R){let D=(R.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);D&&(un=parseInt(D[1].replace(/,/g,""),10))}}let Eo=[...new Set(T.map(R=>(R.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(R=>R&&R.length>1&&R.length<60&&R!==G).filter(R=>g.has(R)))],Le=document.body.textContent||"",xo=/#OpenToWork\b/i.test(Le)||/\bOpen to work\b/.test(Le),_o=/#Hiring\b/i.test(Le)||/\bI'?m hiring\b/i.test(Le)||/\bWe are hiring\b/i.test(Le);return{name:G,title:x,location:q,currentCompany:A,currentSchool:M,connectionDegree:re,hasVerifiedBadge:ie,photoUrl:F,connectionsLevel:H,mutualConnectionsCount:at,followers:un,openToWork:xo,hiring:_o,about:an,topSkills:ln,availableSections:Eo}});console.log(`Viewed: ${f.name} - ${f.title}`);let d=null,m=null,y=null,p=null,S=null,w=null;if(o||s||i||a||l||r){let g=await Promise.resolve().then(()=>(fo(),uo));o&&(d=await g.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),s&&(m=await g.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${m.length} entries`)),i&&(y=await g.extractEducationFromDetails(e,t),console.log(` + Education: ${y.length} entries`)),a&&(p=await g.extractSkillsFromDetails(e,t),console.log(` + Skills: ${p.length} entries`)),l&&(S=await g.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${S.length} entries`)),r&&(w=await g.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${w.length} entries`))}return{...f,profileUrl:t,...d!==null&&{experience:d},...m!==null&&{featured:m},...y!==null&&{education:y},...p!==null&&{skillsFull:p},...S!==null&&{recommendations:S},...w!==null&&{certifications:w}}}catch(u){console.error(`Error viewing profile ${t}:`,u.message);try{await e.goto("about:blank",{timeout:1e4}),await $(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(u.message||""))throw u;return null}}async function xe(e){let t=await e.evaluate(()=>{let n='[class*="pymk"], [class*="people-also-viewed"], [class*="browse-map"], [class*="discover"], [class*="similar"], aside',o=u=>u&&!u.closest(n),s=u=>Array.from(document.querySelectorAll(u)).filter(o),i=s('button[aria-label*="Pending"], a[aria-label*="Pending"]'),a=s('button[aria-label*="Message"], a[aria-label*="Message"]')[0]||null,l=s('button[aria-label*="Invite"][aria-label*="connect"], button[aria-label="Connect"], a[href*="custom-invite"]')[0]||null,r={pendingCount:i.length,pendingLabels:i.map(u=>u.getAttribute("aria-label")),hasMessageBtn:!!a,hasConnectBtn:!!l};return i.length>0?{status:"pending",debug:r}:a&&!l?{status:"connected",debug:r}:document.body.innerText.includes("1st degree connection")?{status:"connected",debug:r}:{status:"not_connected",debug:r}});return console.log(" DEBUG connection status:",JSON.stringify(t.debug)),t.status}async function rt(e){let t=null,n=await e.evaluate(()=>{let r=document.querySelector("h1")?.textContent?.trim();if(r&&!r.includes("notification"))return r;let u=document.querySelector('main h2, [class*="profile"] h2, [class*="top-card"] h2');if(u&&(r=u.textContent?.trim(),r&&!r.includes("notification")))return r;let c=document.querySelector('[class*="text-heading-xlarge"]')||document.querySelector('[class*="profile-card-title"]')||document.querySelector(".pv-text-details__left-panel h1");if(c)return c.textContent?.trim()||"";let f=document.title;return f&&f.includes("|")?f.split("|")[0].trim():""});if(console.log(` Profile name: "${n}"`),n){let r=await e.evaluate(()=>{let c=document.querySelectorAll('a[href*="custom-invite"]');return{count:c.length,labels:Array.from(c).map(f=>f.getAttribute("aria-label")?.slice(0,50))}});r.count>0&&console.log(` S0: ${r.count} custom-invite links: ${JSON.stringify(r.labels)}`),t=await e.evaluateHandle(c=>{let f=document.querySelectorAll('a[href*="custom-invite"]'),d=c.toLowerCase().split(" ")[0],m='[class*="pymk"], [class*="people-also-viewed"], [class*="browse-map"], [class*="discover"], [class*="similar"], aside';for(let y of f){let p=y.getBoundingClientRect();if(p.width===0||p.height===0||y.closest(m))continue;if((y.getAttribute("aria-label")||"").toLowerCase().includes(d))return y}return null},n);let u=t?.asElement?.()||null;if(u||await t?.dispose?.().catch(()=>{}),u)return console.log(" Found: Connect link (new LinkedIn 2025)"),{button:u,method:"connect_link"}}if(n){let r=n.split(" ")[0].toLowerCase();console.log(` Looking for button with name: "${r}"`);let u=await e.evaluate(f=>{let d=new RegExp("\\b"+f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","i"),m=document.querySelectorAll("button[aria-label]");return Array.from(m).filter(p=>{let S=p.getAttribute("aria-label")||"";return(S.toLowerCase().includes("invite")||S.toLowerCase().includes("connect"))&&d.test(S)}).map(p=>p.getAttribute("aria-label")?.slice(0,50))},r);u.length>0&&console.log(` S1: matched buttons: ${JSON.stringify(u)}`),t=await e.evaluateHandle(f=>{let d=document.querySelectorAll("button[aria-label]"),m=new RegExp("\\b"+f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","i");for(let y of d){let p=y.getAttribute("aria-label")||"";if((p.toLowerCase().includes("invite")||p.toLowerCase().includes("connect"))&&m.test(p))return y}return null},r);let c=t?.asElement?.()||null;if(c||await t?.dispose?.().catch(()=>{}),c)return console.log(" Found: button matching profile name"),{button:c,method:"name_matched_button"}}if(t=await e.$('button.artdeco-button--primary[aria-label*="Invite"]:not([class*="sticky-header"]):not([class*="muted"])'),t&&n){let r=await e.evaluate(c=>(c.getAttribute("aria-label")||"").toLowerCase(),t),u=n.split(" ")[0].toLowerCase();r.includes("invite")&&!r.includes(u)&&(console.log(` Skipping primary button: wrong person (${r})`),t=null)}if(t||(t=await e.$('button.artdeco-button--primary[aria-label="Connect"]:not([class*="sticky-header"]):not([class*="muted"])')),t)return console.log(" Found: primary button"),{button:t,method:"primary_button"};let o=await e.$$('button[aria-label*="Invite"][aria-label*="connect"]');o.length===0&&(o=await e.$$('button[aria-label="Connect"]'));let s=n?n.split(" ")[0].toLowerCase():"",i=null;for(let r of o){let u=await e.evaluate((c,f)=>{let d=c.className.includes("muted"),m=c.className.includes("sticky-header")||c.className.includes("sticky"),y=c.closest('[class*="pymk"], [class*="people-also-viewed"], [class*="browse-map"]')!==null,p=(c.getAttribute("aria-label")||"").toLowerCase(),S=p.includes("invite"),w=f?p.includes(f):!0;return{isMuted:d,isStickyHeader:m,inRecommendations:y,hasInvite:S,matchesName:w,ariaLabel:p}},r,s);if(!u.isMuted&&!u.isStickyHeader&&!u.inRecommendations){if(u.hasInvite&&!u.matchesName){console.log(` Skipping secondary button: wrong person (${u.ariaLabel})`);continue}i=r;break}}for(let r of o)r!==i&&await r.dispose().catch(()=>{});if(i)return console.log(" Found: secondary button"),{button:i,method:"secondary_button"};if(t=await e.$('section.pv-supplementary-action button[aria-label*="Invite"]'),t||(t=await e.$('section.pv-supplementary-action button[aria-label="Connect"]')),t)return console.log(" Found: supplementary section"),{button:t,method:"supplementary_section"};console.log(" Trying More actions dropdown...");let a=null,l=await e.$$('button[id*="profile-overflow-action"]');for(let r of l){let u=await e.evaluate(c=>{let f=c.getBoundingClientRect(),d=f.width>0&&f.height>0,m=c.closest('.sticky-header, [class*="sticky"]')!==null;return{isVisible:d,isInStickyHeader:m,top:f.top}},r);if(u.isVisible&&!u.isInStickyHeader){a=r,console.log(" Found More button by ID pattern (main)");break}}for(let r of l)r!==a&&await r.dispose().catch(()=>{});if(!a&&l.length>0&&(a=l[l.length-1],console.log(" Found More button by ID pattern (last)")),a||(a=await e.$('button[aria-label="More actions"]'),a&&console.log(" Found More button by aria-label")),!a){let r=await e.evaluateHandle(()=>{let c=Array.from(document.querySelectorAll("button, a")).find(d=>{let m=d.innerText?.trim(),y=d.getAttribute("aria-label")||"",p=d.getBoundingClientRect();return p.top<100||p.top>600||p.width===0?!1:m==="Follow"||m==="Message"||m==="Connect"||y.includes("Follow")||y.includes("Message")||y.includes("Invite")});if(!c)return null;let f=c.parentElement;for(let d=0;d<8&&f;d++){for(let m of f.querySelectorAll("button"))if(m.innerText?.trim()==="More"&&m!==c)return m;f=f.parentElement}return null});a=r?.asElement?.()||null,a||await r?.dispose?.().catch(()=>{}),a&&console.log(" Found More button by text (near profile actions)")}if(a)try{if(await e.evaluate(c=>c.scrollIntoView({behavior:"smooth",block:"center"}),a),await $(500),await e.evaluate(c=>c.click(),a),await $(2e3),!e.url().includes("/in/"))return console.log(" Redirect detected after More click, aborting"),null;let u=await e.$('.artdeco-dropdown__item[aria-label*="Invite"]');if(u||(u=await e.$('.artdeco-dropdown__item[aria-label*="connect"]')),u||(u=await e.$('.artdeco-dropdown__item[aria-label="Connect"]')),u||(u=await e.$('div[role="button"][aria-label*="Invite"]')),u||(u=await e.$('div[role="button"][aria-label*="connect"]')),!u){let c=await e.evaluateHandle(()=>{let f=document.querySelectorAll('[role="menu"], [popover], .artdeco-dropdown__content');for(let d of f){let m=d.querySelector('a[href*="custom-invite"]');if(m)return m;for(let y of d.querySelectorAll('a, div[role="menuitem"], div[role="button"]'))if(y.innerText?.trim()==="Connect")return y}return null});u=c?.asElement?.()||null,u||await c?.dispose?.().catch(()=>{})}if(!u){let c=await e.evaluate(()=>{let f=document.querySelectorAll('[role="menu"], [popover], .artdeco-dropdown__content'),d=[];for(let m of f)for(let y of m.querySelectorAll('[role="menuitem"], a, div')){let p=y.innerText?.trim();p&&p.length<40&&d.push(p)}return[...new Set(d)].slice(0,10)});console.log(` More dropdown items: ${JSON.stringify(c)}`)}if(u)return console.log(" Found: More dropdown"),{button:u,method:"more_dropdown"};await e.keyboard.press("Escape")}catch(r){console.log(" More dropdown click failed:",r.message),await e.keyboard.press("Escape")}if(t=await e.$('button[aria-label*="Invite"]'),t&&n){let r=await e.evaluate(c=>(c.getAttribute("aria-label")||"").toLowerCase(),t),u=n.split(" ")[0].toLowerCase();r.includes("invite")&&!r.includes(u)&&(console.log(` Skipping generic button: wrong person (${r})`),t=null)}return t||(t=await e.$('button[aria-label="Connect"]')),t?(console.log(" Found: generic button"),{button:t,method:"generic_button"}):null}async function Qt(e,t){await e.evaluate(c=>c.scrollIntoView({behavior:"smooth",block:"center"}),t),await $(500);let n=await e.evaluate(c=>({tag:c.tagName,ariaLabel:c.getAttribute("aria-label"),href:c.getAttribute("href")}),t),s=n.tag==="A"&&n.href&&n.href.includes("custom-invite"),i=n.tag==="DIV",a=(n.ariaLabel||"").toLowerCase();if(a.includes("invite")){let c=await e.evaluate(()=>((document.querySelector("main h1")||document.querySelector("h1")||document.querySelector("main h2"))?.textContent?.trim()||"").split(" ")[0].toLowerCase());if(c&&!a.includes(c))return console.log(` \u2717 Identity guard: control is for someone else ("${n.ariaLabel}") \u2014 refusing to click (target: ${c})`),"wrong_target"}if(s){console.log(" Clicking custom-invite link (will navigate)..."),await Promise.all([e.waitForNavigation({waitUntil:"domcontentloaded",timeout:3e4}).catch(()=>{}),e.evaluate(f=>f.click(),t)]),await $(2e3);let c=e.url();if(c.includes("premium")||c.includes("redeem"))return console.log(" \u26A0 LinkedIn redirected to Premium page - connection limit reached?"),await e.goBack(),await $(2e3),"premium_redirect"}else i?(await e.evaluate(c=>c.click(),t),await $(3e3)):(await e.evaluate(c=>c.click(),t),await $(3e3));let l=e.url();if(l.includes("/premium/")||l.includes("/redeem"))return console.log(" \u26A0 LinkedIn redirected to Premium upsell page"),"premium_redirect";let r=await e.evaluate(()=>!!document.querySelector('[role="dialog"], .artdeco-modal, .send-invite')),u=e.url();return console.log(r?` \u2713 Connect sent \u2014 ${u}`:` \u26A0 No modal after connect click \u2014 ${u}`),"success"}async function Nr(e){console.log(" Upsell: Premium required for notes");let t=await e.$('button[aria-label="Dismiss"]')||await e.$("button.artdeco-modal__dismiss");t?await t.click():await e.keyboard.press("Escape"),await $(1500);let n=await rt(e);if(n){await e.evaluate(s=>s.click(),n),await $(2e3);let o=await e.$('button[aria-label="Send without a note"]');if(o){try{await o.evaluate(s=>s.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (without note)"),!0}}return!1}async function Xt(e,t,n={}){let{source:o="unknown",skipQuotaGate:s=!1,skipQuotaRecord:i=!1}=n;if(!s){let l=Et();if(!l.allowed)return console.log(` \u26A0 Connection quota reached \u2014 not sending: ${l.reason}`),{success:!1,reason:"quota_exhausted",connectionSent:!1,withCustomMessage:!1,messageSent:null,method:null,error:l.reason,profileInfo:null}}let a=await jr(e,t,n);return a.connectionSent&&!i&&_n(t,o),a}async function jr(e,t,n={}){let{message:o=null,useCustomMessage:s=!0,skipIfPending:i=!0,skipIfConnected:a=!0,excludeLocations:l=[]}=n,r={success:!1,reason:null,connectionSent:!1,withCustomMessage:!1,messageSent:null,method:null,error:null,profileInfo:null};try{let u=t.split("/in/")[1]?.replace("/","")||"unknown";if(console.log(`
|
|
239
239
|
--- Connecting: ${u} ---`),l.length>0){let w=J()[t]?.location;if(ht(w,l))return console.log(` \u26A0 Excluded location (stored): ${w}`),r.reason="excluded_location",r.profileInfo={location:w},r}if(await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(5e3),await he(e)&&(console.log(" Dismissed Premium overlay"),await $(2e3),await mo(e,t),await $(2e3)),r.profileInfo=await e.evaluate(()=>{let w=new Set(["Highlights","About","Activity","Experience","Education","Skills","Recommendations","Languages","Interests","Volunteer experience","Featured","Honors & awards","Honors and awards","Projects","Publications","Patents","Certifications","Courses","Test scores","Organizations","More profiles for you","Explore Premium profiles","Suggested for you","Promoted","Ad Options","Don\u2019t want to see this"]),b=j=>{let F=(j||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(F)},g={name:null,title:null,location:null,about:null,company:null,connectionDegree:null,connectionsCount:null,mutualConnections:null,photoUrl:null,hasVerifiedBadge:!1},h=document.querySelector("main");if(!h)return g;let k=[...Array.from(h.querySelectorAll("h1")),...Array.from(h.querySelectorAll("h2"))],C=Array.from(h.querySelectorAll("h2")),_=k.find(j=>{let F=j.textContent&&j.textContent.trim();return F&&F.length>1&&F.length<100&&!w.has(F)&&F!=="0 notifications"}),I=_?_.textContent.trim():null,T=_?_.parentElement:null;for(;T&&T!==h&&!Array.from(T.children).filter(P=>P.tagName==="P").some(P=>{let H=P.textContent&&P.textContent.trim();return H&&H.length>5&&!b(H)});)T=T.parentElement;let L=null,G=null,v=null;if(T&&T!==h){let j=Array.from(T.children),F=j.filter(H=>H.tagName==="P").filter(H=>{let oe=H.textContent&&H.textContent.trim();return oe&&oe.length>5&&!b(oe)});F[0]&&(L=F[0].textContent.trim()),F[1]&&(G=F[1].textContent.trim());let P=j.filter(H=>H.tagName==="DIV");for(let H=P.length-1;H>=0;H--){let oe=P[H].textContent&&P[H].textContent.trim();if(oe&&!(I&&oe.startsWith(I))&&(v=oe.split(/[·•]/)[0].trim(),v))break}}let x=null;if(T){let j=T.querySelectorAll("p, span, div");for(let F of j){let P=(F.textContent||"").trim().replace(/^[·•]\s*/,"");if(P==="1st"||P==="2nd"||P==="3rd"){x=P;break}}}let A=null,M=C.find(j=>j.textContent&&j.textContent.trim()==="About");if(M){let j=M.parentElement;for(;j&&j.tagName!=="SECTION";)j=j.parentElement;j&&(A=(j.textContent||"").trim().replace(/^About\s*/,"").trim()||null,A&&(A=A.replace(/(?:…|\.\.\.)?\s*(?:see (?:more|less)|show (?:more|less))\s*$/i,"").trim()||null))}let q=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),re=q&&q.src||null,ie=!!h.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]');return{name:I,title:L,location:v,about:A,company:G,connectionDegree:x,connectionsCount:null,mutualConnections:null,photoUrl:re,hasVerifiedBadge:ie}}),l.length>0){let w=r.profileInfo?.location,b=J()[t]?.location,g=w||b;if(ht(g,l))return console.log(` \u26A0 Excluded location (${w?"live":"stored"}): ${g}`),r.reason="excluded_location",r;!w&&b==null&&console.log(" \u26A0 Location unknown (live scrape null, no stored value) \u2014 proceeding")}let f=await xe(e);if(f==="pending"&&i)return console.log(" \u26A0 Already pending - skipping"),r.reason="pending",r;if(f==="connected"&&a)return console.log(" \u26A0 Already connected - skipping"),r.reason="connected",r;await he(e);let d=await rt(e);if(!d&&(await he(e)&&(console.log(" Dismissed overlay, retrying connect button search..."),await $(2e3),d=await rt(e)),!d))return console.log(" \u2717 Connect not found"),r.reason="button_not_found",r;r.method=d.method;let m=await Qt(e,d.button);if(m==="wrong_target")return console.log(" \u2717 Not sent \u2014 connect control did not belong to this profile"),r.reason="wrong_target",r;if(m==="premium_redirect"){console.log(" \u26A0 Premium upsell redirect \u2014 navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(4e3);let w=await xe(e);if(w==="pending")return console.log(" \u2713 Connection was sent (detected Pending after upsell redirect)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r;console.log(` Status after upsell: ${w} \u2014 trying More dropdown...`),await he(e),await $(1e3);let b=await e.$('button[id*="profile-overflow-action"]:not([class*="sticky"])');if(b)try{await e.evaluate(h=>h.scrollIntoView({behavior:"smooth",block:"center"}),b),await $(500),await b.click().catch(()=>e.evaluate(h=>h.click(),b)),await $(2e3);let g=await e.$('.artdeco-dropdown__item[aria-label*="Invite"]')||await e.$('.artdeco-dropdown__item[aria-label*="connect"]')||await e.$('.artdeco-dropdown__item[aria-label="Connect"]')||await e.$('div[role="button"][aria-label*="Invite"]')||await e.$('div[role="button"][aria-label*="connect"]');if(g){console.log(" Found Connect in More dropdown, clicking..."),await e.evaluate(C=>C.click(),g),await $(3e3);let h=e.url();if(h.includes("/premium/")||h.includes("/redeem"))return console.log(" \u2717 More dropdown also redirected to Premium"),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),r.reason="premium_required",r;if(await xe(e)==="pending")return console.log(" \u2713 Connection sent via More dropdown"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.method="more_dropdown",r.withCustomMessage=!1,r;console.log(" More dropdown clicked, checking for modal...")}else return console.log(" No Connect option in More dropdown"),await e.keyboard.press("Escape"),await $(500),r.reason="premium_required",r}catch(g){return console.log(" More dropdown failed:",g.message),await e.keyboard.press("Escape").catch(()=>{}),r.reason="premium_required",r}else return console.log(" \u2717 No More button found \u2014 Premium required"),r.reason="premium_required",r}if(await e.$('input[name="email"][type="email"]')){console.log(" \u26A0 Email verification required - skipping");let w=await e.$('button[aria-label="Dismiss"]');return w&&await w.click(),await $(500),r.reason="email_required",r}let p=await e.$('button[aria-label="Add a note"]'),S=await e.$('button[aria-label="Send without a note"]');if(!p&&!S){let w=await e.evaluate(()=>{let b=document.querySelector("#interop-outlet")?.shadowRoot;if(!b)return{addNote:!1,sendWithout:!1};let g=b.querySelector('button[aria-label="Add a note"]'),h=b.querySelector('button[aria-label="Send without a note"]');return{addNote:!!g,sendWithout:!!h}});if(w.addNote){let b=await e.evaluateHandle(()=>document.querySelector("#interop-outlet")?.shadowRoot?.querySelector('button[aria-label="Add a note"]'));p=b?.asElement?.()||null,p||await b.dispose().catch(()=>{})}if(w.sendWithout){let b=await e.evaluateHandle(()=>document.querySelector("#interop-outlet")?.shadowRoot?.querySelector('button[aria-label="Send without a note"]'));S=b?.asElement?.()||null,S||await b.dispose().catch(()=>{})}}if(s){if(p&&o){if(console.log(" Adding personalized note..."),await p.click(),await $(1500),await e.$("div.modal-upsell")){let g=await Nr(e);return r.success=g,r.connectionSent=g,r.reason=g?"sent_without_note_upsell":"upsell_failed",r.withCustomMessage=!1,r}let b=await e.$('textarea[name="message"]')||await e.$("textarea#custom-message")||await e.$("textarea");if(b){let g=await e.evaluate(()=>document.querySelector("h1")?.textContent?.trim()?.split(" ")[0]||""),h=o.replace("{name}",g);await b.type(h,{delay:20}),await $(500);let k=await e.$('button[aria-label="Send invitation"]')||await e.$('button[aria-label="Send now"]');if(k){try{await k.evaluate(C=>C.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (with note)"),r.success=!0,r.connectionSent=!0,r.reason="sent_with_note",r.withCustomMessage=!0,r.messageSent=h,r}}}else if(S){console.log(" Sending without note...");try{await S.evaluate(w=>w.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (without note)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r}else if(p&&!o){console.log(" No message provided, sending without note...");let w=await e.$('button[aria-label="Send without a note"]');if(w){try{await w.evaluate(b=>b.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (without note)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r}}}else{console.log(" Sending without note (custom messages disabled)...");let w=S;if(w){try{await w.evaluate(b=>b.click())}catch{console.log(" Click timeout, likely still sent")}return await $(3e3),console.log(" \u2713 Connection sent (without note)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r}}if(d.method!=="more_dropdown"){console.log(" \u26A0 No modal after click \u2014 trying More dropdown fallback..."),e.url().includes("/in/")||(await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(4e3)),await he(e),await $(500);let b=await e.$$('button[id*="profile-overflow-action"]'),g=null;for(let h of b){let k=await e.evaluate(C=>{let _=C.getBoundingClientRect();return{visible:_.width>0&&_.height>0,inSticky:!!C.closest('.sticky-header, [class*="sticky"]')}},h);if(k.visible&&!k.inSticky){g=h;break}}!g&&b.length>0&&(g=b[b.length-1]);for(let h of b)h!==g&&await h.dispose().catch(()=>{});if(g)try{await e.evaluate(k=>k.scrollIntoView({behavior:"smooth",block:"center"}),g),await $(500),await g.click().catch(()=>e.evaluate(k=>k.click(),g)),await $(2e3);let h=await e.$('.artdeco-dropdown__item[aria-label*="Invite"]')||await e.$('.artdeco-dropdown__item[aria-label*="connect"]')||await e.$('.artdeco-dropdown__item[aria-label="Connect"]')||await e.$('div[role="button"][aria-label*="Invite"]')||await e.$('div[role="button"][aria-label*="connect"]');if(h){console.log(" Found Connect in More dropdown, clicking..."),r.method="more_dropdown",await e.evaluate(I=>I.click(),h),await $(3e3);let k=e.url();if(k.includes("/premium/")||k.includes("/redeem"))return console.log(" \u2717 More dropdown also redirected to Premium"),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),await xe(e)==="pending"?(console.log(" \u2713 Connection was sent (detected Pending)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r):(r.reason="premium_required",r);if(await xe(e)==="pending")return console.log(" \u2713 Connection sent via More dropdown"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r;let _=await e.$('button[aria-label="Send without a note"]');if(_){console.log(" Modal appeared via More dropdown, sending without note...");try{await _.evaluate(I=>I.click())}catch{}return await $(3e3),console.log(" \u2713 Connection sent (without note, via More dropdown)"),r.success=!0,r.connectionSent=!0,r.reason="sent_without_note",r.withCustomMessage=!1,r}console.log(" More dropdown: no modal either")}else console.log(" No Connect option in More dropdown"),await e.keyboard.press("Escape")}catch(h){console.log(" More dropdown fallback failed:",h.message),await e.keyboard.press("Escape").catch(()=>{})}}return console.log(" \u2717 Could not complete connection request"),r.reason="modal_failed",r}catch(u){console.error(` \u2717 Error: ${u.message}`),r.reason="error",r.error=u.message;let c=u.message.toLowerCase();if(c.includes("detached")||c.includes("session closed")||c.includes("target closed")||c.includes("browser has disconnected")||c.includes("protocol error"))return r.fatal=!0,r;try{await e.goto("about:blank",{timeout:1e4}),await $(1e3)}catch{r.fatal=!0}return r}}async function po(e,t,n={}){let{message:o=null,useCustomMessage:s=!0,maxConnections:i=20,viewOnly:a=!1,delayBetweenProfiles:l=3e3,onProfileProcessed:r=null,excludeLocations:u=[],source:c="unknown"}=n,f={viewed:0,connectionsSent:0,skipped:{pending:0,connected:0,email:0,notFound:0,excludedLocation:0},errors:0};if(console.log(`
|
|
240
240
|
=== Running Funnel: ${t.length} profiles ===`),console.log(`Mode: ${a?"View Only":`Connect (max ${i})`}`),a||console.log(`Custom messages: ${s?"Enabled":"Disabled (saving quota)"}`),u.length>0&&console.log(`Excluding locations: ${u.join(", ")}`),!a){let m=ze();console.log(`Quota: today ${m.daily.sent}/${m.daily.max} | week ${m.weekly.sent}/${m.weekly.max}`)}console.log("");let d=0;for(let m=0;m<t.length;m++){let y=t[m];try{if(e.isClosed()){console.log(`
|
|
241
241
|
\u26A0 Browser page is closed \u2014 aborting funnel`);break}}catch{console.log(`
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{fileURLToPath as r}from"url";function i(){return"1.14.
|
|
1
|
+
import{readFileSync as e}from"fs";import{fileURLToPath as r}from"url";function i(){return"1.14.4";try{let n=new URL("./ilml-plugin.json",import.meta.url);return JSON.parse(e(r(n),"utf-8")).version}catch{return"unknown"}}console.log(`ilml-plugin-linkedin ${i()}`);
|
package/ilml-plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkedin",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"description": "Reference ilml plugin: keep a local mirror of your LinkedIn data with AI-assisted workflows",
|
|
5
5
|
"commands": {
|
|
6
6
|
"help": { "run": "node dist/help.mjs", "description": "List all commands with descriptions; or `help <cmd>` for detailed info on one command (usage, flags, ban-risk, when-to-use). Reads ilml-plugin.json directly.", "usage": "ilml linkedin help [<cmd>]", "useWhen": "You forgot what a command does, or you're an AI agent picking the right tool." },
|
package/package.json
CHANGED