ilml-plugin-linkedin 1.13.1 → 1.14.0
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 +22 -0
- package/README.md +7 -4
- package/dist/connect.mjs +325 -0
- package/dist/enrichProfile.mjs +3 -3
- package/dist/enrichProfiles.mjs +7 -7
- package/dist/funnelRunner.mjs +32 -32
- package/dist/messageBot.mjs +8 -8
- package/dist/quota.mjs +8 -0
- package/dist/run.mjs +48 -48
- package/dist/src/saveLoginState.mjs +3 -3
- package/dist/syncAll.mjs +38 -38
- package/dist/verifyAbout.mjs +7 -7
- package/dist/version.mjs +1 -0
- package/dist/viewers.mjs +9 -9
- package/dist/warmScan.mjs +3 -5
- package/ilml-plugin.json +37 -3
- package/package.json +4 -3
- package/target-companies.json +0 -58
package/dist/enrichProfile.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Xe=Object.defineProperty;var Ae=(t,e)=>()=>(t&&(e=t(t=0)),e);var et=(t,e)=>{for(var n in e)Xe(t,n,{get:e[n],enumerable:!0})};async function w(t){let e=Math.floor(Math.random()*2001),n=t+e;return new Promise(o=>setTimeout(o,n))}async function $e(t){return await t.evaluate(()=>{let e=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of e){let i=o.innerText||"",s=i.includes("Premium")||i.includes("premium")||i.includes("Upgrade")||i.includes("upgrade"),f=i.includes("Try for")||i.includes("free trial")||i.includes("/month")||i.includes("per month")||i.includes("Start my")||i.includes("Subscribe"),d=i.includes("Get hired faster")||i.includes("Get hired 2x");if(s||f||d){let D=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:i.substring(0,80)};let $=o.querySelectorAll("button");for(let a of $){let S=a.innerText?.trim().toLowerCase()||"",p=a.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||p.includes("dismiss"))return a.click(),{dismissed:!0,matched:i.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var re=Ae(()=>{});var Ne={};et(Ne,{extractCertificationsFromDetails:()=>bt,extractEducationFromDetails:()=>gt,extractExperienceFromDetails:()=>ht,extractFeaturedFromDetails:()=>wt,extractRecommendationsFromDetails:()=>St,extractSkillsFromDetails:()=>yt});async function ht(t,e){let n=e.replace(/\/+$/,"")+"/details/experience/";try{await t.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let s=0;s<5;s++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(900);await w(1e3);let i=0;for(;i<5&&await t.evaluate(()=>{for(let f of document.querySelectorAll("button"))if(/^Load more$/i.test((f.textContent||"").trim()))return f.click(),!0;return!1});)i++,await w(1500),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);return await t.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function f(a){let S=[];for(let p of a.querySelectorAll("div")){let h=Array.from(p.children).filter(v=>v.tagName==="DIV");if(h.length<3)continue;let y=h.filter(v=>(v.textContent||"").trim().length>50);y.length<3||(p.textContent||"").length<500||S.push({el:p,count:y.length,totalText:(p.textContent||"").length})}return S.sort((p,h)=>h.count-p.count||p.totalText-h.totalText),S[0]?.el}let d=f(s);if(!d)return[];let D=Array.from(d.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function $(a){let S=a[0]||null,p=null,h=null;if(a[1]){let c=a[1].split("\xB7").map(k=>k.trim());p=c[0]||null,c[1]&&(h=c[1])}let y=a.findIndex(c=>/(\d{4}|present)/i.test(c)&&/(-|–|—)/i.test(c)&&c.length<80),v=null,L=null;if(y>=0){let c=a[y].split("\xB7").map(k=>k.trim());v=c[0]||null,c[1]&&(L=c[1])}let
|
|
1
|
+
var Xe=Object.defineProperty;var Ae=(t,e)=>()=>(t&&(e=t(t=0)),e);var et=(t,e)=>{for(var n in e)Xe(t,n,{get:e[n],enumerable:!0})};async function w(t){let e=Math.floor(Math.random()*2001),n=t+e;return new Promise(o=>setTimeout(o,n))}async function $e(t){return await t.evaluate(()=>{let e=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of e){let i=o.innerText||"",s=i.includes("Premium")||i.includes("premium")||i.includes("Upgrade")||i.includes("upgrade"),f=i.includes("Try for")||i.includes("free trial")||i.includes("/month")||i.includes("per month")||i.includes("Start my")||i.includes("Subscribe"),d=i.includes("Get hired faster")||i.includes("Get hired 2x");if(s||f||d){let D=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:i.substring(0,80)};let $=o.querySelectorAll("button");for(let a of $){let S=a.innerText?.trim().toLowerCase()||"",p=a.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||p.includes("dismiss"))return a.click(),{dismissed:!0,matched:i.substring(0,80)}}}}let n=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(n){let o=n.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||n.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(o)return o.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var re=Ae(()=>{});var Ne={};et(Ne,{extractCertificationsFromDetails:()=>bt,extractEducationFromDetails:()=>gt,extractExperienceFromDetails:()=>ht,extractFeaturedFromDetails:()=>wt,extractRecommendationsFromDetails:()=>St,extractSkillsFromDetails:()=>yt});async function ht(t,e){let n=e.replace(/\/+$/,"")+"/details/experience/";try{await t.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();if(/\/(login|authwall|checkpoint)/i.test(o))throw new Error(`Session expired \u2014 bounced to ${o} when fetching /details/experience/`);for(let s=0;s<5;s++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(900);await w(1e3);let i=0;for(;i<5&&await t.evaluate(()=>{for(let f of document.querySelectorAll("button"))if(/^Load more$/i.test((f.textContent||"").trim()))return f.click(),!0;return!1});)i++,await w(1500),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);return await t.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function f(a){let S=[];for(let p of a.querySelectorAll("div")){let h=Array.from(p.children).filter(v=>v.tagName==="DIV");if(h.length<3)continue;let y=h.filter(v=>(v.textContent||"").trim().length>50);y.length<3||(p.textContent||"").length<500||S.push({el:p,count:y.length,totalText:(p.textContent||"").length})}return S.sort((p,h)=>h.count-p.count||p.totalText-h.totalText),S[0]?.el}let d=f(s);if(!d)return[];let D=Array.from(d.children).filter(a=>a.tagName==="DIV").filter(a=>(a.textContent||"").trim().length>50);function $(a){let S=a[0]||null,p=null,h=null;if(a[1]){let c=a[1].split("\xB7").map(k=>k.trim());p=c[0]||null,c[1]&&(h=c[1])}let y=a.findIndex(c=>/(\d{4}|present)/i.test(c)&&/(-|–|—)/i.test(c)&&c.length<80),v=null,L=null;if(y>=0){let c=a[y].split("\xB7").map(k=>k.trim());v=c[0]||null,c[1]&&(L=c[1])}let M=null,ne=-1;if(y>=0&&a[y+1]){let c=a[y+1],k=/^[>*\-•]|^>/.test(c),P=/https?:\/\//.test(c),x=/\d{4}/.test(c),V=/,/.test(c)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(c);!k&&!P&&!x&&c.length<100&&V&&(M=c,ne=y+1)}let b=null,j=-1,I=a[a.length-1];if(I&&/and\s+\+\d+\s+skills?$/i.test(I)){j=a.length-1;let c=I.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);c&&(b={listed:c[1].split(",").map(k=>k.trim()),additional:parseInt(c[2],10)})}let T=new Set([0,1,y,ne,j].filter(c=>c>=0)),C=a.filter((c,k)=>!T.has(k)),oe=C.length>0?C.join(`
|
|
2
2
|
|
|
3
|
-
`):null;return{title:S,company:p,employmentType:h,dates:v,duration:L,location:
|
|
3
|
+
`):null;return{title:S,company:p,employmentType:h,dates:v,duration:L,location:M,description:oe,skills:b,_raw:a}}return D.map(a=>{let p=(a.innerText||"").trim().split(`
|
|
4
4
|
`).map(h=>h.trim()).filter(h=>h&&h.length<5e3);return $(p)}).filter(a=>a.title)})}catch(o){if(/session expired|bounced to|authwall|checkpoint/i.test(o.message||""))throw o;return console.error(`extractExperienceFromDetails failed for ${e}: ${o.message?.slice(0,120)}`),[]}}async function B(t,e,n){let o=e.replace(/\/+$/,"")+`/details/${n}/`;await t.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let i=t.url();if(/\/(login|authwall|checkpoint)/i.test(i))throw new Error(`Session expired \u2014 bounced to ${i} when fetching /details/${n}/`);if(!i.toLowerCase().includes(`/details/${n.toLowerCase()}/`))throw new Error(`Section /details/${n}/ not available on profile (landed on ${i})`);for(let f=0;f<4;f++)await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(700);await w(800);let s=0;for(;s<5&&await t.evaluate(()=>{for(let d of document.querySelectorAll("button"))if(/^Load more$/i.test((d.textContent||"").trim()))return d.click(),!0;return!1});)s++,await w(1300),await t.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await w(600)}async function U(t,e,n,o){try{return await o()}catch(i){let s=i.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(s))throw i;return/not available on profile/i.test(s)?(console.log(` (${e}: section not on profile \u2014 skipped)`),[]):(console.error(`${n} failed for ${t}: ${s.slice(0,120)}`),[])}}async function wt(t,e){return U(e,"featured","extractFeaturedFromDetails",async()=>(await B(t,e,"featured"),await t.evaluate(`(() => {
|
|
5
5
|
${H}
|
|
6
6
|
|
|
@@ -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
|
-
`});import"dotenv/config";import Et from"puppeteer";re();import{getPluginConfig as tt}from"@ilivemylife/graph-sdk";var nt=await tt();for(let[t,e]of Object.entries(nt))process.env[t]===void 0&&(process.env[t]=e);var Dt=process.env.LINKEDIN_NAME,M=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Lt=Object.freeze(new Set([M.DRAFT,M.CONFIRMED,M.NEEDS_REVIEW])),Tt=Object.freeze(new Set([M.DRAFT,M.CONFIRMED,M.REJECTED,M.NEEDS_REVIEW]));import"dotenv/config";import*as m from"fs";import*as g from"path";import{fileURLToPath as ot}from"url";var it=ot(import.meta.url),st=g.dirname(g.dirname(it)),A=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(st,"collected-profiles"),le=g.join(A,"people.json"),jt=g.join(A,"jobs.json"),Pt=g.join(A,"quota.json"),Ot=g.join(A,"conversations.json"),qt=g.join(A,"sync-state.json"),Bt=g.join(A,"application-questions.json"),ae=g.join(A,"profile-history");var q=null;function Le(){m.existsSync(A)||m.mkdirSync(A,{recursive:!0})}function Te(t,e){let n=JSON.stringify(e,null,2),o=t+".tmp";m.writeFileSync(o,n);for(let i=0;i<3;i++)try{m.renameSync(o,t);return}catch(s){if(i<2&&(s.code==="EPERM"||s.code==="EBUSY")){let f=Date.now();for(;Date.now()-f<200;);continue}throw s}}function Fe(t,e){if(!m.existsSync(t))return null;try{let n=JSON.parse(m.readFileSync(t,"utf-8"));try{m.copyFileSync(t,t+".backup")}catch{}return n}catch(n){console.error(`[!] ${e} is corrupted: ${n.message}`),console.error(` File: ${g.resolve(t)}`);let o=t+".backup";if(m.existsSync(o))try{let i=JSON.parse(m.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{m.copyFileSync(o,t)}catch{}return i}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${t}.corrupted`);try{m.copyFileSync(t,t+".corrupted")}catch{}return null}}function rt(){return new Date().toISOString().split("T")[0]}var lt=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],at=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function ce(t){if(!t)return null;let e=t.match(/\/in\/([^/?#]+)/);return e?e[1].toLowerCase():null}function ct(){m.existsSync(ae)||m.mkdirSync(ae,{recursive:!0})}function Me(t){let e=ce(t);return e?g.join(ae,`${e}.json`):null}function ut(t){let e=Me(t);return e?Fe(e,`profile-history/${ce(t)}.json`)||[]:[]}function dt(t,e){let n=Me(t);if(!n)return;ct();let o=ut(t);o.unshift(e);try{Te(n,o)}catch(i){console.error(`[!] Failed to append profile-history for ${ce(t)}: ${i.message}`)}}function _e(t){return!!(t==null||Array.isArray(t)&&t.length===0||typeof t=="string"&&!t.trim())}function De(t){return Array.isArray(t)?[...t].map(e=>String(e).trim()).sort().join("||"):typeof t=="string"?t.replace(/\s+/g," ").trim():t}function ft(t,e){if(!t)return[];let n=[];for(let o of at){let i=t[o],s=e[o];_e(i)||_e(s)||De(i)!==De(s)&&n.push(o)}return n}function mt(t){let e=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,i]of Object.entries(t))e.has(o)||(n[o]=i);return n}function Re(){return q||(Le(),q=Fe(le,"people.json")||{},q)}function pt(t){Le(),q=t;try{Te(le,t)}catch(e){console.error(`[!] Failed to save people.json: ${e.message}`),console.error(` Path: ${g.resolve(le)}`)}}function ue(t,e={}){if(!t)return null;let n=Re(),o=rt(),i=new Date().toISOString(),s=n[t];if(s){let f=ft(s,e);f.length>0&&(dt(t,{capturedAt:i,previousLastUpdated:s.lastUpdated||null,changedFields:f,snapshot:mt(s)}),s.lastSnapshotAt=i),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=i,e.source&&!s.sources?.includes(e.source)&&(s.sources=s.sources||[],s.sources.push(e.source));for(let d of lt)if(e[d]!=null){if(Array.isArray(e[d])&&e[d].length===0&&Array.isArray(s[d])&&s[d].length>0)continue;s[d]=e[d]}Array.isArray(e.availableSections)&&(s.lastFullVisitAt=i)}else n[t]={name:e.name||null,title:e.title||null,location:e.location||null,company:e.company||null,about:e.about||null,connectionDegree:e.connectionDegree||null,connectionsCount:e.connectionsCount||null,mutualConnections:e.mutualConnections||null,photoUrl:e.photoUrl||null,hasVerifiedBadge:e.hasVerifiedBadge||!1,currentCompany:e.currentCompany||null,currentSchool:e.currentSchool||null,connectionsLevel:e.connectionsLevel||null,mutualConnectionsCount:e.mutualConnectionsCount||null,followers:e.followers||null,openToWork:e.openToWork||!1,hiring:e.hiring||!1,topSkills:e.topSkills||null,availableSections:e.availableSections||null,experience:e.experience||null,featuredLinks:e.featuredLinks||null,_lastEnrichedAt:e._lastEnrichedAt||null,featured:e.featured||null,education:e.education||null,skillsFull:e.skillsFull||null,recommendations:e.recommendations||null,certifications:e.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:e.source?[e.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:i,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(e.availableSections)?i:null};return pt(n),n[t]}async function kt(t,e){let n=t.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 t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function Pe(t,e,n={}){let{extractExperience:o=!1,extractFeatured:i=!1,extractEducation:s=!1,extractSkills:f=!1,extractRecommendations:d=!1,extractCertifications:D=!1}=n;try{await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3),await $e(t)&&(console.log(" Dismissed Premium overlay"),await w(1500),await kt(t,e));let a=0;for(let b=0;b<2;b++){let j=await t.evaluate(()=>document.body.scrollHeight);for(let F=1;F<=6;F++)await t.evaluate(C=>window.scrollTo(0,C),j*F/6),await w(900);let I=await t.evaluate(()=>document.body.scrollHeight);if(I===a)break;a=I}await w(800);let S=await t.evaluate(()=>{let b=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"]),j=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"]),I=r=>{let l=(r||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(l)},F={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:[]},C=document.querySelector("main");if(!C)return F;let oe=[...Array.from(C.querySelectorAll("h1")),...Array.from(C.querySelectorAll("h2"))],c=Array.from(C.querySelectorAll("h2")),k=oe.find(r=>{let l=r.textContent&&r.textContent.trim(),u=(l||"").replace(/\s*\(\d+\)$/,"").trim();return l&&l.length>1&&l.length<100&&!b.has(u)&&!j.has(u)}),P=k?k.textContent.trim():null,x=k?k.parentElement:null;for(;x&&x!==C&&!Array.from(x.children).filter(l=>l.tagName==="P").some(l=>{let u=l.textContent&&l.textContent.trim();return u&&u.length>5&&!I(u)});)x=x.parentElement;let V=null,pe=null,he=null,ie=null;if(x&&x!==C){let r=Array.from(x.children).filter(u=>u.tagName==="P").filter(u=>{let _=u.textContent&&u.textContent.trim();return _&&_.length>5&&!I(_)});if(r[0]&&(V=r[0].textContent.trim()),r[1]){let u=r[1].textContent.trim().split(/\s*[·•]\s*/);pe=u[0]||null,u.length>1&&(he=u.slice(1).join(" \xB7 "))}let l=Array.from(x.children).filter(u=>u.tagName==="DIV");for(let u=l.length-1;u>=0;u--){let _=l[u].textContent&&l[u].textContent.trim();if(_&&!(P&&_.startsWith(P))&&(ie=_.split(/[·•]/)[0].trim(),ie))break}}let we=null;if(x){let r=x.querySelectorAll("p, span, div");for(let l of r){let u=(l.textContent||"").trim().replace(/^[·•]\s*/,"");if(u==="1st"||u==="2nd"||u==="3rd"){we=u;break}}}let Je=!!C.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ge=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ke=ge&&ge.src||null,W=C.textContent||"",ye=null,be=W.match(/(\d+\+?)\s+connections\b/i);be&&(ye=be[1]+" connections");let J=null,Se=W.match(/(\d+)\s+mutual connection/i),ke=W.match(/and\s+(\d+)\s+other mutual/i),Ye=W.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Se?J=parseInt(Se[1],10):ke?J=2+parseInt(ke[1],10):Ye&&(J=2);let Ce=null,xe=null,ve=c.find(r=>r.textContent&&r.textContent.trim()==="About");if(ve){let r=ve.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").trim();l=l.replace(/^About\s*/,"").trim();let u=l.match(/Top skills\s*(.+?)$/i);if(u){let se=u[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Ze=>Ze.trim()).filter(Boolean);se.length>0&&se.length<10&&(xe=se)}l=l.split(/\n?…\s*more/i)[0].trim(),l=l.split(/\n?\.\.\.\s*more/i)[0].trim(),l=l.split(/\bTop skills\b/i)[0].trim(),l=l.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Ce=l||null}}let Ee=null,Ie=c.find(r=>r.textContent&&r.textContent.trim()==="Activity");if(Ie){let r=Ie.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);l&&(Ee=parseInt(l[1].replace(/,/g,""),10))}}let Ge=[...new Set(c.map(r=>(r.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(r=>r&&r.length>1&&r.length<60&&r!==P).filter(r=>b.has(r)))],O=document.body.textContent||"",Qe=/#OpenToWork\b/i.test(O)||/\bOpen to work\b/.test(O),ze=/#Hiring\b/i.test(O)||/\bI'?m hiring\b/i.test(O)||/\bWe are hiring\b/i.test(O);return{name:P,title:V,location:ie,currentCompany:pe,currentSchool:he,connectionDegree:we,hasVerifiedBadge:Je,photoUrl:Ke,connectionsLevel:ye,mutualConnectionsCount:J,followers:Ee,openToWork:Qe,hiring:ze,about:Ce,topSkills:xe,availableSections:Ge}});console.log(`Viewed: ${S.name} - ${S.title}`);let p=null,h=null,y=null,v=null,L=null,T=null;if(o||i||s||f||d||D){let b=await Promise.resolve().then(()=>(je(),Ne));o&&(p=await b.extractExperienceFromDetails(t,e),console.log(` + Experience: ${p.length} entries`)),i&&(h=await b.extractFeaturedFromDetails(t,e),console.log(` + Featured: ${h.length} entries`)),s&&(y=await b.extractEducationFromDetails(t,e),console.log(` + Education: ${y.length} entries`)),f&&(v=await b.extractSkillsFromDetails(t,e),console.log(` + Skills: ${v.length} entries`)),d&&(L=await b.extractRecommendationsFromDetails(t,e),console.log(` + Recommendations: ${L.length} entries`)),D&&(T=await b.extractCertificationsFromDetails(t,e),console.log(` + Certifications: ${T.length} entries`))}return{...S,profileUrl:e,...p!==null&&{experience:p},...h!==null&&{featured:h},...y!==null&&{education:y},...v!==null&&{skillsFull:v},...L!==null&&{recommendations:L},...T!==null&&{certifications:T}}}catch($){console.error(`Error viewing profile ${e}:`,$.message);try{await t.goto("about:blank",{timeout:1e4}),await w(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test($.message||""))throw $;return null}}import Oe from"fs";import Ct from"path";var xt="cookies.json";function vt(){let t=process.env.ILML_SCOPE_DIR;return t?Ct.join(t,"plugins-state","linkedin","cookies.json"):xt}function qe(){let t=vt();if(!Oe.existsSync(t))throw new Error(`Cookies not found at ${t}. Run: ilml linkedin login`);let e;try{e=Oe.readFileSync(t,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${t}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(e)}catch{throw new Error(`Cookies file at ${t} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${t} is empty or not an array. Run: ilml linkedin login`);return n}function Be(t){return t?t.replace(/^https?:\/\/(www\.|m\.)?linkedin\.com/i,"https://linkedin.com").split("?")[0].split("#")[0].replace(/\/+$/,"").toLowerCase():""}function He(t){return(t||"").replace(/ /g," ").replace(/\s+/g," ").trim().toLowerCase()}var E=process.argv.slice(2),It=E.includes("--help")||E.includes("-h"),R=E.find(t=>t.startsWith("http")),N=E.includes("--full"),Y=N||E.includes("--with-experience"),G=N||E.includes("--with-featured"),Q=N||E.includes("--with-education"),z=N||E.includes("--with-skills"),Z=N||E.includes("--with-recommendations"),X=N||E.includes("--with-certifications"),Ue=[["experience",Y],["featured",G],["education",Q],["skills",z],["recommendations",Z],["certifications",X]],Ve=Ue.filter(([,t])=>t).length,fe=1+Ve;function We(){console.log(`
|
|
238
|
+
`});import"dotenv/config";import Et from"puppeteer";re();import{getPluginConfig as tt}from"@ilivemylife/graph-sdk";var nt=await tt();for(let[t,e]of Object.entries(nt))process.env[t]===void 0&&(process.env[t]=e);var Dt=process.env.LINKEDIN_NAME,F=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Lt=Object.freeze(new Set([F.DRAFT,F.CONFIRMED,F.NEEDS_REVIEW])),Mt=Object.freeze(new Set([F.DRAFT,F.CONFIRMED,F.REJECTED,F.NEEDS_REVIEW]));import"dotenv/config";import*as m from"fs";import*as g from"path";import{fileURLToPath as ot}from"url";var it=ot(import.meta.url),st=g.dirname(g.dirname(it)),A=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(st,"collected-profiles"),le=g.join(A,"people.json"),jt=g.join(A,"jobs.json"),Pt=g.join(A,"quota.json"),Ot=g.join(A,"conversations.json"),qt=g.join(A,"sync-state.json"),Bt=g.join(A,"application-questions.json"),ae=g.join(A,"profile-history");var q=null;function Le(){m.existsSync(A)||m.mkdirSync(A,{recursive:!0})}function Me(t,e){let n=JSON.stringify(e,null,2),o=t+".tmp";m.writeFileSync(o,n);for(let i=0;i<3;i++)try{m.renameSync(o,t);return}catch(s){if(i<2&&(s.code==="EPERM"||s.code==="EBUSY")){let f=Date.now();for(;Date.now()-f<200;);continue}throw s}}function Te(t,e){if(!m.existsSync(t))return null;try{let n=JSON.parse(m.readFileSync(t,"utf-8"));try{m.copyFileSync(t,t+".backup")}catch{}return n}catch(n){console.error(`[!] ${e} is corrupted: ${n.message}`),console.error(` File: ${g.resolve(t)}`);let o=t+".backup";if(m.existsSync(o))try{let i=JSON.parse(m.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{m.copyFileSync(o,t)}catch{}return i}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${t}.corrupted`);try{m.copyFileSync(t,t+".corrupted")}catch{}return null}}function rt(){return new Date().toISOString().split("T")[0]}var lt=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],at=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function ce(t){if(!t)return null;let e=t.match(/\/in\/([^/?#]+)/);return e?e[1].toLowerCase():null}function ct(){m.existsSync(ae)||m.mkdirSync(ae,{recursive:!0})}function Fe(t){let e=ce(t);return e?g.join(ae,`${e}.json`):null}function ut(t){let e=Fe(t);return e?Te(e,`profile-history/${ce(t)}.json`)||[]:[]}function dt(t,e){let n=Fe(t);if(!n)return;ct();let o=ut(t);o.unshift(e);try{Me(n,o)}catch(i){console.error(`[!] Failed to append profile-history for ${ce(t)}: ${i.message}`)}}function _e(t){return!!(t==null||Array.isArray(t)&&t.length===0||typeof t=="string"&&!t.trim())}function De(t){return Array.isArray(t)?[...t].map(e=>String(e).trim()).sort().join("||"):typeof t=="string"?t.replace(/\s+/g," ").trim():t}function ft(t,e){if(!t)return[];let n=[];for(let o of at){let i=t[o],s=e[o];_e(i)||_e(s)||De(i)!==De(s)&&n.push(o)}return n}function mt(t){let e=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,i]of Object.entries(t))e.has(o)||(n[o]=i);return n}function Re(){return q||(Le(),q=Te(le,"people.json")||{},q)}function pt(t){Le(),q=t;try{Me(le,t)}catch(e){console.error(`[!] Failed to save people.json: ${e.message}`),console.error(` Path: ${g.resolve(le)}`)}}function ue(t,e={}){if(!t)return null;let n=Re(),o=rt(),i=new Date().toISOString(),s=n[t];if(s){let f=ft(s,e);f.length>0&&(dt(t,{capturedAt:i,previousLastUpdated:s.lastUpdated||null,changedFields:f,snapshot:mt(s)}),s.lastSnapshotAt=i),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=i,e.source&&!s.sources?.includes(e.source)&&(s.sources=s.sources||[],s.sources.push(e.source));for(let d of lt)if(e[d]!=null){if(Array.isArray(e[d])&&e[d].length===0&&Array.isArray(s[d])&&s[d].length>0)continue;s[d]=e[d]}Array.isArray(e.availableSections)&&(s.lastFullVisitAt=i)}else n[t]={name:e.name||null,title:e.title||null,location:e.location||null,company:e.company||null,about:e.about||null,connectionDegree:e.connectionDegree||null,connectionsCount:e.connectionsCount||null,mutualConnections:e.mutualConnections||null,photoUrl:e.photoUrl||null,hasVerifiedBadge:e.hasVerifiedBadge||!1,currentCompany:e.currentCompany||null,currentSchool:e.currentSchool||null,connectionsLevel:e.connectionsLevel||null,mutualConnectionsCount:e.mutualConnectionsCount||null,followers:e.followers||null,openToWork:e.openToWork||!1,hiring:e.hiring||!1,topSkills:e.topSkills||null,availableSections:e.availableSections||null,experience:e.experience||null,featuredLinks:e.featuredLinks||null,_lastEnrichedAt:e._lastEnrichedAt||null,featured:e.featured||null,education:e.education||null,skillsFull:e.skillsFull||null,recommendations:e.recommendations||null,certifications:e.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:e.source?[e.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:i,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(e.availableSections)?i:null};return pt(n),n[t]}async function kt(t,e){let n=t.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 t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3);let o=t.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function Pe(t,e,n={}){let{extractExperience:o=!1,extractFeatured:i=!1,extractEducation:s=!1,extractSkills:f=!1,extractRecommendations:d=!1,extractCertifications:D=!1}=n;try{await t.goto(e,{waitUntil:"domcontentloaded",timeout:6e4}),await w(3e3),await $e(t)&&(console.log(" Dismissed Premium overlay"),await w(1500),await kt(t,e));let a=0;for(let b=0;b<2;b++){let j=await t.evaluate(()=>document.body.scrollHeight);for(let T=1;T<=6;T++)await t.evaluate(C=>window.scrollTo(0,C),j*T/6),await w(900);let I=await t.evaluate(()=>document.body.scrollHeight);if(I===a)break;a=I}await w(800);let S=await t.evaluate(()=>{let b=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"]),j=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"]),I=r=>{let l=(r||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(l)},T={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:[]},C=document.querySelector("main");if(!C)return T;let oe=[...Array.from(C.querySelectorAll("h1")),...Array.from(C.querySelectorAll("h2"))],c=Array.from(C.querySelectorAll("h2")),k=oe.find(r=>{let l=r.textContent&&r.textContent.trim(),u=(l||"").replace(/\s*\(\d+\)$/,"").trim();return l&&l.length>1&&l.length<100&&!b.has(u)&&!j.has(u)}),P=k?k.textContent.trim():null,x=k?k.parentElement:null;for(;x&&x!==C&&!Array.from(x.children).filter(l=>l.tagName==="P").some(l=>{let u=l.textContent&&l.textContent.trim();return u&&u.length>5&&!I(u)});)x=x.parentElement;let V=null,pe=null,he=null,ie=null;if(x&&x!==C){let r=Array.from(x.children).filter(u=>u.tagName==="P").filter(u=>{let _=u.textContent&&u.textContent.trim();return _&&_.length>5&&!I(_)});if(r[0]&&(V=r[0].textContent.trim()),r[1]){let u=r[1].textContent.trim().split(/\s*[·•]\s*/);pe=u[0]||null,u.length>1&&(he=u.slice(1).join(" \xB7 "))}let l=Array.from(x.children).filter(u=>u.tagName==="DIV");for(let u=l.length-1;u>=0;u--){let _=l[u].textContent&&l[u].textContent.trim();if(_&&!(P&&_.startsWith(P))&&(ie=_.split(/[·•]/)[0].trim(),ie))break}}let we=null;if(x){let r=x.querySelectorAll("p, span, div");for(let l of r){let u=(l.textContent||"").trim().replace(/^[·•]\s*/,"");if(u==="1st"||u==="2nd"||u==="3rd"){we=u;break}}}let Je=!!C.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),ge=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Ke=ge&&ge.src||null,W=C.textContent||"",ye=null,be=W.match(/(\d+\+?)\s+connections\b/i);be&&(ye=be[1]+" connections");let J=null,Se=W.match(/(\d+)\s+mutual connection/i),ke=W.match(/and\s+(\d+)\s+other mutual/i),Ye=W.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Se?J=parseInt(Se[1],10):ke?J=2+parseInt(ke[1],10):Ye&&(J=2);let Ce=null,xe=null,ve=c.find(r=>r.textContent&&r.textContent.trim()==="About");if(ve){let r=ve.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").trim();l=l.replace(/^About\s*/,"").trim();let u=l.match(/Top skills\s*(.+?)$/i);if(u){let se=u[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Ze=>Ze.trim()).filter(Boolean);se.length>0&&se.length<10&&(xe=se)}l=l.split(/\n?…\s*more/i)[0].trim(),l=l.split(/\n?\.\.\.\s*more/i)[0].trim(),l=l.split(/\bTop skills\b/i)[0].trim(),l=l.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Ce=l||null}}let Ee=null,Ie=c.find(r=>r.textContent&&r.textContent.trim()==="Activity");if(Ie){let r=Ie.parentElement;for(;r&&r.tagName!=="SECTION";)r=r.parentElement;if(r){let l=(r.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);l&&(Ee=parseInt(l[1].replace(/,/g,""),10))}}let Ge=[...new Set(c.map(r=>(r.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(r=>r&&r.length>1&&r.length<60&&r!==P).filter(r=>b.has(r)))],O=document.body.textContent||"",Qe=/#OpenToWork\b/i.test(O)||/\bOpen to work\b/.test(O),ze=/#Hiring\b/i.test(O)||/\bI'?m hiring\b/i.test(O)||/\bWe are hiring\b/i.test(O);return{name:P,title:V,location:ie,currentCompany:pe,currentSchool:he,connectionDegree:we,hasVerifiedBadge:Je,photoUrl:Ke,connectionsLevel:ye,mutualConnectionsCount:J,followers:Ee,openToWork:Qe,hiring:ze,about:Ce,topSkills:xe,availableSections:Ge}});console.log(`Viewed: ${S.name} - ${S.title}`);let p=null,h=null,y=null,v=null,L=null,M=null;if(o||i||s||f||d||D){let b=await Promise.resolve().then(()=>(je(),Ne));o&&(p=await b.extractExperienceFromDetails(t,e),console.log(` + Experience: ${p.length} entries`)),i&&(h=await b.extractFeaturedFromDetails(t,e),console.log(` + Featured: ${h.length} entries`)),s&&(y=await b.extractEducationFromDetails(t,e),console.log(` + Education: ${y.length} entries`)),f&&(v=await b.extractSkillsFromDetails(t,e),console.log(` + Skills: ${v.length} entries`)),d&&(L=await b.extractRecommendationsFromDetails(t,e),console.log(` + Recommendations: ${L.length} entries`)),D&&(M=await b.extractCertificationsFromDetails(t,e),console.log(` + Certifications: ${M.length} entries`))}return{...S,profileUrl:e,...p!==null&&{experience:p},...h!==null&&{featured:h},...y!==null&&{education:y},...v!==null&&{skillsFull:v},...L!==null&&{recommendations:L},...M!==null&&{certifications:M}}}catch($){console.error(`Error viewing profile ${e}:`,$.message);try{await t.goto("about:blank",{timeout:1e4}),await w(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test($.message||""))throw $;return null}}import Oe from"fs";import Ct from"path";var xt="cookies.json";function vt(){let t=process.env.ILML_SCOPE_DIR;return t?Ct.join(t,"plugins-state","linkedin","cookies.json"):xt}function qe(){let t=vt();if(!Oe.existsSync(t))throw new Error(`Cookies not found at ${t}. Run: ilml linkedin login`);let e;try{e=Oe.readFileSync(t,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${t}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(e)}catch{throw new Error(`Cookies file at ${t} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${t} is empty or not an array. Run: ilml linkedin login`);return n}function Be(t){return t?t.replace(/^https?:\/\/(www\.|m\.)?linkedin\.com/i,"https://linkedin.com").split("?")[0].split("#")[0].replace(/\/+$/,"").toLowerCase():""}function He(t){return(t||"").replace(/ /g," ").replace(/\s+/g," ").trim().toLowerCase()}var E=process.argv.slice(2),It=E.includes("--help")||E.includes("-h"),R=E.find(t=>t.startsWith("http")),N=E.includes("--full"),Y=N||E.includes("--with-experience"),G=N||E.includes("--with-featured"),Q=N||E.includes("--with-education"),z=N||E.includes("--with-skills"),Z=N||E.includes("--with-recommendations"),X=N||E.includes("--with-certifications"),Ue=[["experience",Y],["featured",G],["education",Q],["skills",z],["recommendations",Z],["certifications",X]],Ve=Ue.filter(([,t])=>t).length,fe=1+Ve;function We(){console.log(`
|
|
239
239
|
enrich-profile \u2014 visit ONE LinkedIn profile and save what we learn
|
|
240
240
|
|
|
241
241
|
USAGE
|
package/dist/enrichProfiles.mjs
CHANGED
|
@@ -238,14 +238,14 @@ function findEntryContainer(root) {
|
|
|
238
238
|
`});import en from"puppeteer";import{addExtra as tn}from"puppeteer-extra";import nn from"puppeteer-extra-plugin-stealth";ie();import{getPluginConfig as Gt}from"@ilivemylife/graph-sdk";var Yt=await Gt();for(let[e,t]of Object.entries(Yt))process.env[e]===void 0&&(process.env[e]=t);var Kt=process.env.LINKEDIN_NAME,Y=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Uo=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.NEEDS_REVIEW])),zt=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.REJECTED,Y.NEEDS_REVIEW]));import rt from"fs";import Qt from"path";var Zt="cookies.json";function Xt(){let e=process.env.ILML_SCOPE_DIR;return e?Qt.join(e,"plugins-state","linkedin","cookies.json"):Zt}function st(){let e=Xt();if(!rt.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=rt.readFileSync(e,"utf-8")}catch(o){throw new Error(`Failed to read cookies at ${e}: ${o.message}. Run: ilml linkedin login`)}let n;try{n=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(n)||n.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return n}var it=tn(en);it.use(nn());async function lt(){let e=await it.launch({headless:!1,defaultViewport:null,protocolTimeout:3e5}),t=async()=>{console.log(`
|
|
239
239
|
Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t);let n=await e.newPage();await n.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let o=st();await n.setCookie(...o),console.log(" Browser launched, cookies loaded.")}catch(o){console.error(`
|
|
240
240
|
[!] ${o.message}
|
|
241
|
-
`),await e.close(),process.exit(1)}return{browser:e,page:n}}ie();import"dotenv/config";import*as C from"fs";import*as x from"path";import{fileURLToPath as on}from"url";var rn=on(import.meta.url),sn=x.dirname(x.dirname(rn)),q=process.env.DATA_DIR?x.resolve(process.env.DATA_DIR,"collected-profiles"):x.join(sn,"collected-profiles"),ke=x.join(q,"people.json"),sr=x.join(q,"jobs.json"),ir=x.join(q,"quota.json"),ut=x.join(q,"conversations.json"),lr=x.join(q,"sync-state.json"),ar=x.join(q,"application-questions.json"),Ce=x.join(q,"profile-history");var re=null,ln=null,an=null,oe=null,cn=null,un=null;function dt(){re=null,ln=null,an=null,oe=null,cn=null,un=null}function xe(){C.existsSync(q)||C.mkdirSync(q,{recursive:!0})}function $e(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";C.writeFileSync(o,n);for(let r=0;r<3;r++)try{C.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function Ee(e,t){if(!C.existsSync(e))return null;try{let n=JSON.parse(C.readFileSync(e,"utf-8"));try{C.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${x.resolve(e)}`);let o=e+".backup";if(C.existsSync(o))try{let r=JSON.parse(C.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{C.copyFileSync(o,e)}catch{}return r}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{C.copyFileSync(e,e+".corrupted")}catch{}return null}}function dn(){return new Date().toISOString().split("T")[0]}var fn=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],mn=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function Ae(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function pn(){C.existsSync(Ce)||C.mkdirSync(Ce,{recursive:!0})}function ft(e){let t=Ae(e);return t?x.join(Ce,`${t}.json`):null}function hn(e){let t=ft(e);return t?Ee(t,`profile-history/${Ae(e)}.json`)||[]:[]}function gn(e,t){let n=ft(e);if(!n)return;pn();let o=hn(e);o.unshift(t);try{$e(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${Ae(e)}: ${r.message}`)}}function at(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function ct(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function yn(e,t){if(!e)return[];let n=[];for(let o of mn){let r=e[o],s=t[o];at(r)||at(s)||ct(r)!==ct(s)&&n.push(o)}return n}function wn(e){let t=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,r]of Object.entries(e))t.has(o)||(n[o]=r);return n}function K(){return re||(xe(),re=Ee(ke,"people.json")||{},re)}function bn(e){xe(),re=e;try{$e(ke,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${x.resolve(ke)}`)}}function _e(){return oe||(xe(),oe=Ee(ut,"conversations.json")||{},Sn(oe),oe)}function Sn(e){let t=0;for(let n of Object.values(e)){if(!(n.draftStatus!==void 0||n.draftPreparedAt!==void 0))continue;let r=(n.messages||[]).find(s=>s.status==="draft");r&&n.draftStatus&&n.draftStatus!=="pending"&&(r.status=n.draftStatus),delete n.draftStatus,delete n.draftPreparedAt,t++}if(t>0){console.log(` [migration] Moved draft state from conv to msg.status for ${t} conversations`);try{$e(ut,e)}catch{}}}function Ie(e,t={}){if(!e)return null;let n=K(),o=dn(),r=new Date().toISOString(),s=n[e];if(s){let l=yn(s,t);l.length>0&&(gn(e,{capturedAt:r,previousLastUpdated:s.lastUpdated||null,changedFields:l,snapshot:wn(s)}),s.lastSnapshotAt=r),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=r,t.source&&!s.sources?.includes(t.source)&&(s.sources=s.sources||[],s.sources.push(t.source));for(let i of fn)if(t[i]!=null){if(Array.isArray(t[i])&&t[i].length===0&&Array.isArray(s[i])&&s[i].length>0)continue;s[i]=t[i]}Array.isArray(t.availableSections)&&(s.lastFullVisitAt=r)}else n[e]={name:t.name||null,title:t.title||null,location:t.location||null,company:t.company||null,about:t.about||null,connectionDegree:t.connectionDegree||null,connectionsCount:t.connectionsCount||null,mutualConnections:t.mutualConnections||null,photoUrl:t.photoUrl||null,hasVerifiedBadge:t.hasVerifiedBadge||!1,currentCompany:t.currentCompany||null,currentSchool:t.currentSchool||null,connectionsLevel:t.connectionsLevel||null,mutualConnectionsCount:t.mutualConnectionsCount||null,followers:t.followers||null,openToWork:t.openToWork||!1,hiring:t.hiring||!1,topSkills:t.topSkills||null,availableSections:t.availableSections||null,experience:t.experience||null,featuredLinks:t.featuredLinks||null,_lastEnrichedAt:t._lastEnrichedAt||null,featured:t.featured||null,education:t.education||null,skillsFull:t.skillsFull||null,recommendations:t.recommendations||null,certifications:t.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:t.source?[t.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:r,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?r:null};return bn(n),n[e]}async function An(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 k(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function ht(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:l=!1,extractRecommendations:i=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await k(1500),await An(e,t));let c=0;for(let $=0;$<2;$++){let te=await e.evaluate(()=>document.body.scrollHeight);for(let G=1;G<=6;G++)await e.evaluate(I=>window.scrollTo(0,I),te*G/6),await k(900);let P=await e.evaluate(()=>document.body.scrollHeight);if(P===c)break;c=P}await k(800);let m=await e.evaluate(()=>{let $=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"]),te=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"]),P=h=>{let g=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(g)},G={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:[]},I=document.querySelector("main");if(!I)return G;let be=[...Array.from(I.querySelectorAll("h1")),...Array.from(I.querySelectorAll("h2"))],y=Array.from(I.querySelectorAll("h2")),A=be.find(h=>{let g=h.textContent&&h.textContent.trim(),w=(g||"").replace(/\s*\(\d+\)$/,"").trim();return g&&g.length>1&&g.length<100&&!$.has(w)&&!te.has(w)}),ne=A?A.textContent.trim():null,T=A?A.parentElement:null;for(;T&&T!==I&&!Array.from(T.children).filter(g=>g.tagName==="P").some(g=>{let w=g.textContent&&g.textContent.trim();return w&&w.length>5&&!P(w)});)T=T.parentElement;let de=null,Ve=null,He=null,Se=null;if(T&&T!==I){let h=Array.from(T.children).filter(w=>w.tagName==="P").filter(w=>{let B=w.textContent&&w.textContent.trim();return B&&B.length>5&&!P(B)});if(h[0]&&(de=h[0].textContent.trim()),h[1]){let w=h[1].textContent.trim().split(/\s*[·•]\s*/);Ve=w[0]||null,w.length>1&&(He=w.slice(1).join(" \xB7 "))}let g=Array.from(T.children).filter(w=>w.tagName==="DIV");for(let w=g.length-1;w>=0;w--){let B=g[w].textContent&&g[w].textContent.trim();if(B&&!(ne&&B.startsWith(ne))&&(Se=B.split(/[·•]/)[0].trim(),Se))break}}let Je=null;if(T){let h=T.querySelectorAll("p, span, div");for(let g of h){let w=(g.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){Je=w;break}}}let Pt=!!I.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),We=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),qt=We&&We.src||null,fe=I.textContent||"",Ge=null,Ye=fe.match(/(\d+\+?)\s+connections\b/i);Ye&&(Ge=Ye[1]+" connections");let me=null,Ke=fe.match(/(\d+)\s+mutual connection/i),ze=fe.match(/and\s+(\d+)\s+other mutual/i),Ut=fe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?me=parseInt(Ke[1],10):ze?me=2+parseInt(ze[1],10):Ut&&(me=2);let Qe=null,Ze=null,Xe=y.find(h=>h.textContent&&h.textContent.trim()==="About");if(Xe){let h=Xe.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").trim();g=g.replace(/^About\s*/,"").trim();let w=g.match(/Top skills\s*(.+?)$/i);if(w){let ve=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Jt=>Jt.trim()).filter(Boolean);ve.length>0&&ve.length<10&&(Ze=ve)}g=g.split(/\n?…\s*more/i)[0].trim(),g=g.split(/\n?\.\.\.\s*more/i)[0].trim(),g=g.split(/\bTop skills\b/i)[0].trim(),g=g.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=g||null}}let et=null,tt=y.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(tt){let h=tt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);g&&(et=parseInt(g[1].replace(/,/g,""),10))}}let Bt=[...new Set(y.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ne).filter(h=>$.has(h)))],se=document.body.textContent||"",Vt=/#OpenToWork\b/i.test(se)||/\bOpen to work\b/.test(se),Ht=/#Hiring\b/i.test(se)||/\bI'?m hiring\b/i.test(se)||/\bWe are hiring\b/i.test(se);return{name:ne,title:de,location:Se,currentCompany:Ve,currentSchool:He,connectionDegree:Je,hasVerifiedBadge:Pt,photoUrl:qt,connectionsLevel:Ge,mutualConnectionsCount:me,followers:et,openToWork:Vt,hiring:Ht,about:Qe,topSkills:Ze,availableSections:Bt}});console.log(`Viewed: ${m.name} - ${m.title}`);let d=null,p=null,v=null,b=null,E=null,W=null;if(o||r||s||l||i||a){let $=await Promise.resolve().then(()=>(pt(),mt));o&&(d=await $.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),r&&(p=await $.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${p.length} entries`)),s&&(v=await $.extractEducationFromDetails(e,t),console.log(` + Education: ${v.length} entries`)),l&&(b=await $.extractSkillsFromDetails(e,t),console.log(` + Skills: ${b.length} entries`)),i&&(E=await $.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${E.length} entries`)),a&&(W=await $.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${W.length} entries`))}return{...m,profileUrl:t,...d!==null&&{experience:d},...p!==null&&{featured:p},...v!==null&&{education:v},...b!==null&&{skillsFull:b},...E!==null&&{recommendations:E},...W!==null&&{certifications:W}}}catch(f){console.error(`Error viewing profile ${t}:`,f.message);try{await e.goto("about:blank",{timeout:1e4}),await k(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(f.message||""))throw f;return null}}import"dotenv/config";import*as O from"fs";import*as D from"path";import{fileURLToPath as _n}from"url";var In=_n(import.meta.url),Tn=D.dirname(D.dirname(In)),Q=process.env.DATA_DIR?D.resolve(process.env.DATA_DIR,"market-research"):D.join(Tn,"market-research"),kr=D.join(Q,"scouted-jobs.json"),Cr=D.join(Q,"discovered-people.json"),gt=D.join(Q,"visit-log.json"),xr=D.join(Q,"companies.json"),$r=D.join(Q,"job-decisions.json");function Rn(){O.existsSync(Q)||O.mkdirSync(Q,{recursive:!0})}function Dn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";O.writeFileSync(o,n);for(let r=0;r<3;r++)try{O.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function On(e){try{if(O.existsSync(e))return JSON.parse(O.readFileSync(e,"utf-8"))}catch{}return null}function yt(){jn=null,Nn=null,Ln=null,Fn=null,z=null}var jn=null;var Nn=null;var Ln=null;var Fn=null;var z=null;function Te(){return z||(z=On(gt)||{visits:[]},Array.isArray(z.visits)||(z.visits=[]),z)}function wt(e,t={}){if(!e)return;Rn();let n=Te();n.visits.push({date:new Date().toISOString(),profileUrl:e,name:t.name||null,source:t.source||"manual"});let o=Date.now()-90*24*60*60*1e3;n.visits=n.visits.filter(r=>new Date(r.date).getTime()>o);try{Dn(gt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function bt(e){let t=Te();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}ie();async function St(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:l=!1,extractExperience:i=!1}=n,a={visited:0,skipped:0,errors:0},f=Date.now()-s*24*60*60*1e3;for(let c of t){if(a.visited>=o)break;if(!c.profileUrl)continue;let m=bt(c.profileUrl);if(m&&new Date(m).getTime()>f){a.skipped++;continue}try{let d=await ht(e,c.profileUrl,{extractExperience:i}),p=c.source||"visit";if(d){let b={...d,source:p};i&&Array.isArray(d.experience)&&d.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Ie(c.profileUrl,b)}wt(c.profileUrl,{name:d?.name||c.name||null,source:p}),a.visited++,l?console.log(` [${a.visited}] ${d?.name||c.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let v=Math.random()*4e3;await k(r+v)}catch(d){a.errors++,l&&console.error(` Error visiting ${c.name||c.profileUrl}: ${d.message?.slice(0,60)}`);let p=(d.message||"").toLowerCase();if(p.includes("detached")||p.includes("session closed")||p.includes("target closed")||p.includes("session expired")||p.includes("bounced to")||p.includes("authwall")||p.includes("checkpoint")||p.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}import"dotenv/config";import*as j from"fs";import*as V from"path";import{fileURLToPath as Vn}from"url";import"dotenv/config";import{createGraphClient as Mn,resolveToken as Pn}from"@ilivemylife/graph-sdk";import{config as qn}from"dotenv";qn();var vt=Pn()||process.env.TOKEN;vt||(console.error(`
|
|
241
|
+
`),await e.close(),process.exit(1)}return{browser:e,page:n}}ie();import"dotenv/config";import*as C from"fs";import*as x from"path";import{fileURLToPath as on}from"url";var rn=on(import.meta.url),sn=x.dirname(x.dirname(rn)),q=process.env.DATA_DIR?x.resolve(process.env.DATA_DIR,"collected-profiles"):x.join(sn,"collected-profiles"),ke=x.join(q,"people.json"),sr=x.join(q,"jobs.json"),ir=x.join(q,"quota.json"),ut=x.join(q,"conversations.json"),lr=x.join(q,"sync-state.json"),ar=x.join(q,"application-questions.json"),Ce=x.join(q,"profile-history");var re=null,ln=null,an=null,oe=null,cn=null,un=null;function dt(){re=null,ln=null,an=null,oe=null,cn=null,un=null}function xe(){C.existsSync(q)||C.mkdirSync(q,{recursive:!0})}function $e(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";C.writeFileSync(o,n);for(let r=0;r<3;r++)try{C.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function Ee(e,t){if(!C.existsSync(e))return null;try{let n=JSON.parse(C.readFileSync(e,"utf-8"));try{C.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${x.resolve(e)}`);let o=e+".backup";if(C.existsSync(o))try{let r=JSON.parse(C.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{C.copyFileSync(o,e)}catch{}return r}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{C.copyFileSync(e,e+".corrupted")}catch{}return null}}function dn(){return new Date().toISOString().split("T")[0]}var fn=["name","title","location","company","connectionDegree","connectionsCount","mutualConnections","photoUrl","hasVerifiedBadge","about","currentCompany","currentSchool","connectionsLevel","mutualConnectionsCount","followers","openToWork","hiring","topSkills","availableSections","experience","featuredLinks","_lastEnrichedAt","featured","education","skillsFull","recommendations","certifications"],mn=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function Ae(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function pn(){C.existsSync(Ce)||C.mkdirSync(Ce,{recursive:!0})}function ft(e){let t=Ae(e);return t?x.join(Ce,`${t}.json`):null}function hn(e){let t=ft(e);return t?Ee(t,`profile-history/${Ae(e)}.json`)||[]:[]}function gn(e,t){let n=ft(e);if(!n)return;pn();let o=hn(e);o.unshift(t);try{$e(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${Ae(e)}: ${r.message}`)}}function at(e){return!!(e==null||Array.isArray(e)&&e.length===0||typeof e=="string"&&!e.trim())}function ct(e){return Array.isArray(e)?[...e].map(t=>String(t).trim()).sort().join("||"):typeof e=="string"?e.replace(/\s+/g," ").trim():e}function yn(e,t){if(!e)return[];let n=[];for(let o of mn){let r=e[o],s=t[o];at(r)||at(s)||ct(r)!==ct(s)&&n.push(o)}return n}function wn(e){let t=new Set(["seenCount","sources","firstSeen","lastSeen","lastUpdated","encounters","jobIds","lastFullVisitAt","lastSnapshotAt","messageSent","connectionStatus","connectionDate","connectionMethod"]),n={};for(let[o,r]of Object.entries(e))t.has(o)||(n[o]=r);return n}function K(){return re||(xe(),re=Ee(ke,"people.json")||{},re)}function bn(e){xe(),re=e;try{$e(ke,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${x.resolve(ke)}`)}}function _e(){return oe||(xe(),oe=Ee(ut,"conversations.json")||{},Sn(oe),oe)}function Sn(e){let t=0;for(let n of Object.values(e)){if(!(n.draftStatus!==void 0||n.draftPreparedAt!==void 0))continue;let r=(n.messages||[]).find(s=>s.status==="draft");r&&n.draftStatus&&n.draftStatus!=="pending"&&(r.status=n.draftStatus),delete n.draftStatus,delete n.draftPreparedAt,t++}if(t>0){console.log(` [migration] Moved draft state from conv to msg.status for ${t} conversations`);try{$e(ut,e)}catch{}}}function Ie(e,t={}){if(!e)return null;let n=K(),o=dn(),r=new Date().toISOString(),s=n[e];if(s){let l=yn(s,t);l.length>0&&(gn(e,{capturedAt:r,previousLastUpdated:s.lastUpdated||null,changedFields:l,snapshot:wn(s)}),s.lastSnapshotAt=r),s.seenCount=(s.seenCount||1)+1,s.lastSeen=o,s.lastUpdated=r,t.source&&!s.sources?.includes(t.source)&&(s.sources=s.sources||[],s.sources.push(t.source));for(let i of fn)if(t[i]!=null){if(Array.isArray(t[i])&&t[i].length===0&&Array.isArray(s[i])&&s[i].length>0)continue;s[i]=t[i]}Array.isArray(t.availableSections)&&(s.lastFullVisitAt=r)}else n[e]={name:t.name||null,title:t.title||null,location:t.location||null,company:t.company||null,about:t.about||null,connectionDegree:t.connectionDegree||null,connectionsCount:t.connectionsCount||null,mutualConnections:t.mutualConnections||null,photoUrl:t.photoUrl||null,hasVerifiedBadge:t.hasVerifiedBadge||!1,currentCompany:t.currentCompany||null,currentSchool:t.currentSchool||null,connectionsLevel:t.connectionsLevel||null,mutualConnectionsCount:t.mutualConnectionsCount||null,followers:t.followers||null,openToWork:t.openToWork||!1,hiring:t.hiring||!1,topSkills:t.topSkills||null,availableSections:t.availableSections||null,experience:t.experience||null,featuredLinks:t.featuredLinks||null,_lastEnrichedAt:t._lastEnrichedAt||null,featured:t.featured||null,education:t.education||null,skillsFull:t.skillsFull||null,recommendations:t.recommendations||null,certifications:t.certifications||null,firstSeen:o,lastSeen:o,seenCount:1,sources:t.source?[t.source]:[],connectionStatus:null,connectionDate:null,connectionMethod:null,messageSent:null,jobIds:[],lastUpdated:r,lastSnapshotAt:null,lastFullVisitAt:Array.isArray(t.availableSections)?r:null};return bn(n),n[e]}async function An(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 k(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function ht(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:l=!1,extractRecommendations:i=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await k(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await k(1500),await An(e,t));let c=0;for(let $=0;$<2;$++){let te=await e.evaluate(()=>document.body.scrollHeight);for(let G=1;G<=6;G++)await e.evaluate(I=>window.scrollTo(0,I),te*G/6),await k(900);let P=await e.evaluate(()=>document.body.scrollHeight);if(P===c)break;c=P}await k(800);let m=await e.evaluate(()=>{let $=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"]),te=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"]),P=h=>{let g=(h||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(g)},G={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:[]},I=document.querySelector("main");if(!I)return G;let be=[...Array.from(I.querySelectorAll("h1")),...Array.from(I.querySelectorAll("h2"))],y=Array.from(I.querySelectorAll("h2")),A=be.find(h=>{let g=h.textContent&&h.textContent.trim(),w=(g||"").replace(/\s*\(\d+\)$/,"").trim();return g&&g.length>1&&g.length<100&&!$.has(w)&&!te.has(w)}),ne=A?A.textContent.trim():null,T=A?A.parentElement:null;for(;T&&T!==I&&!Array.from(T.children).filter(g=>g.tagName==="P").some(g=>{let w=g.textContent&&g.textContent.trim();return w&&w.length>5&&!P(w)});)T=T.parentElement;let de=null,Ve=null,He=null,Se=null;if(T&&T!==I){let h=Array.from(T.children).filter(w=>w.tagName==="P").filter(w=>{let B=w.textContent&&w.textContent.trim();return B&&B.length>5&&!P(B)});if(h[0]&&(de=h[0].textContent.trim()),h[1]){let w=h[1].textContent.trim().split(/\s*[·•]\s*/);Ve=w[0]||null,w.length>1&&(He=w.slice(1).join(" \xB7 "))}let g=Array.from(T.children).filter(w=>w.tagName==="DIV");for(let w=g.length-1;w>=0;w--){let B=g[w].textContent&&g[w].textContent.trim();if(B&&!(ne&&B.startsWith(ne))&&(Se=B.split(/[·•]/)[0].trim(),Se))break}}let Je=null;if(T){let h=T.querySelectorAll("p, span, div");for(let g of h){let w=(g.textContent||"").trim().replace(/^[·•]\s*/,"");if(w==="1st"||w==="2nd"||w==="3rd"){Je=w;break}}}let Pt=!!I.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),We=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),qt=We&&We.src||null,fe=I.textContent||"",Ge=null,Ye=fe.match(/(\d+\+?)\s+connections\b/i);Ye&&(Ge=Ye[1]+" connections");let me=null,Ke=fe.match(/(\d+)\s+mutual connection/i),ze=fe.match(/and\s+(\d+)\s+other mutual/i),Ut=fe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?me=parseInt(Ke[1],10):ze?me=2+parseInt(ze[1],10):Ut&&(me=2);let Qe=null,Ze=null,Xe=y.find(h=>h.textContent&&h.textContent.trim()==="About");if(Xe){let h=Xe.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").trim();g=g.replace(/^About\s*/,"").trim();let w=g.match(/Top skills\s*(.+?)$/i);if(w){let ve=w[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Jt=>Jt.trim()).filter(Boolean);ve.length>0&&ve.length<10&&(Ze=ve)}g=g.split(/\n?…\s*more/i)[0].trim(),g=g.split(/\n?\.\.\.\s*more/i)[0].trim(),g=g.split(/\bTop skills\b/i)[0].trim(),g=g.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=g||null}}let et=null,tt=y.find(h=>h.textContent&&h.textContent.trim()==="Activity");if(tt){let h=tt.parentElement;for(;h&&h.tagName!=="SECTION";)h=h.parentElement;if(h){let g=(h.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);g&&(et=parseInt(g[1].replace(/,/g,""),10))}}let Bt=[...new Set(y.map(h=>(h.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(h=>h&&h.length>1&&h.length<60&&h!==ne).filter(h=>$.has(h)))],se=document.body.textContent||"",Vt=/#OpenToWork\b/i.test(se)||/\bOpen to work\b/.test(se),Ht=/#Hiring\b/i.test(se)||/\bI'?m hiring\b/i.test(se)||/\bWe are hiring\b/i.test(se);return{name:ne,title:de,location:Se,currentCompany:Ve,currentSchool:He,connectionDegree:Je,hasVerifiedBadge:Pt,photoUrl:qt,connectionsLevel:Ge,mutualConnectionsCount:me,followers:et,openToWork:Vt,hiring:Ht,about:Qe,topSkills:Ze,availableSections:Bt}});console.log(`Viewed: ${m.name} - ${m.title}`);let d=null,p=null,v=null,b=null,E=null,W=null;if(o||r||s||l||i||a){let $=await Promise.resolve().then(()=>(pt(),mt));o&&(d=await $.extractExperienceFromDetails(e,t),console.log(` + Experience: ${d.length} entries`)),r&&(p=await $.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${p.length} entries`)),s&&(v=await $.extractEducationFromDetails(e,t),console.log(` + Education: ${v.length} entries`)),l&&(b=await $.extractSkillsFromDetails(e,t),console.log(` + Skills: ${b.length} entries`)),i&&(E=await $.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${E.length} entries`)),a&&(W=await $.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${W.length} entries`))}return{...m,profileUrl:t,...d!==null&&{experience:d},...p!==null&&{featured:p},...v!==null&&{education:v},...b!==null&&{skillsFull:b},...E!==null&&{recommendations:E},...W!==null&&{certifications:W}}}catch(f){console.error(`Error viewing profile ${t}:`,f.message);try{await e.goto("about:blank",{timeout:1e4}),await k(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(f.message||""))throw f;return null}}import"dotenv/config";import*as j from"fs";import*as D from"path";import{fileURLToPath as _n}from"url";var In=_n(import.meta.url),Tn=D.dirname(D.dirname(In)),Q=process.env.DATA_DIR?D.resolve(process.env.DATA_DIR,"market-research"):D.join(Tn,"market-research"),kr=D.join(Q,"scouted-jobs.json"),Cr=D.join(Q,"discovered-people.json"),gt=D.join(Q,"visit-log.json"),xr=D.join(Q,"companies.json"),$r=D.join(Q,"job-decisions.json");function Rn(){j.existsSync(Q)||j.mkdirSync(Q,{recursive:!0})}function Dn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";j.writeFileSync(o,n);for(let r=0;r<3;r++)try{j.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function jn(e){try{if(j.existsSync(e))return JSON.parse(j.readFileSync(e,"utf-8"))}catch{}return null}function yt(){On=null,Nn=null,Ln=null,Fn=null,z=null}var On=null;var Nn=null;var Ln=null;var Fn=null;var z=null;function Te(){return z||(z=jn(gt)||{visits:[]},Array.isArray(z.visits)||(z.visits=[]),z)}function wt(e,t={}){if(!e)return;Rn();let n=Te();n.visits.push({date:new Date().toISOString(),profileUrl:e,name:t.name||null,source:t.source||"manual"});let o=Date.now()-90*24*60*60*1e3;n.visits=n.visits.filter(r=>new Date(r.date).getTime()>o);try{Dn(gt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function bt(e){let t=Te();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}ie();async function St(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:l=!1,extractExperience:i=!1}=n,a={visited:0,skipped:0,errors:0},f=Date.now()-s*24*60*60*1e3;for(let c of t){if(a.visited>=o)break;if(!c.profileUrl)continue;let m=bt(c.profileUrl);if(m&&new Date(m).getTime()>f){a.skipped++;continue}try{let d=await ht(e,c.profileUrl,{extractExperience:i}),p=c.source||"visit";if(d){let b={...d,source:p};i&&Array.isArray(d.experience)&&d.experience.length>0&&(b._lastEnrichedAt=new Date().toISOString()),Ie(c.profileUrl,b)}wt(c.profileUrl,{name:d?.name||c.name||null,source:p}),a.visited++,l?console.log(` [${a.visited}] ${d?.name||c.profileUrl} \u2014 ${d?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let v=Math.random()*4e3;await k(r+v)}catch(d){a.errors++,l&&console.error(` Error visiting ${c.name||c.profileUrl}: ${d.message?.slice(0,60)}`);let p=(d.message||"").toLowerCase();if(p.includes("detached")||p.includes("session closed")||p.includes("target closed")||p.includes("session expired")||p.includes("bounced to")||p.includes("authwall")||p.includes("checkpoint")||p.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}import"dotenv/config";import*as O from"fs";import*as V from"path";import{fileURLToPath as Vn}from"url";import"dotenv/config";import{createGraphClient as Mn,resolveToken as Pn}from"@ilivemylife/graph-sdk";import{config as qn}from"dotenv";qn();var vt=Pn()||process.env.TOKEN;vt||(console.error(`
|
|
242
242
|
[FATAL] No iLiveMyLife token found.`),console.error(" The bot uses Lifebot AI to decide which jobs to apply for"),console.error(` and how to fill application forms. It cannot work without it.
|
|
243
243
|
`),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
|
|
244
244
|
`),console.error(` Or add ILML_TOKEN=... to .env
|
|
245
245
|
`),process.exit(1));var kt=Mn({token:vt});function Un(e){if(!e||e<1e3)return`${e||0}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),o=t%60;return o?`${n}m ${o}s`:`${n}m`}function Bn({scriptName:e,mode:t,status:n,error:o,duration:r}){let s=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",l=new Date().toISOString().slice(0,16).replace("T"," "),i=r?` ${Un(r)}`:"",a=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",f=t&&t!=="default"?` (${t})`:"";return`${s} ${e}${f} \u2014 ${a} \u2014 ${l}${i}`}async function Ct({scriptName:e,mode:t,status:n,summaryLines:o,error:r,duration:s}){let l=process.env.NODE_RUN_REPORTS;if(!l||!Array.isArray(o)||o.length===0)return;let a=`**${Bn({scriptName:e,mode:t,status:n,error:r,duration:s})}**
|
|
246
246
|
|
|
247
247
|
${o.join(`
|
|
248
|
-
`)}`;try{await kt.addMessage(l,a)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var Hn=Vn(import.meta.url),Jn=V.dirname(V.dirname(Hn)),Re=process.env.DATA_DIR?V.resolve(process.env.DATA_DIR,"collected-profiles"):V.join(Jn,"collected-profiles"),De=V.join(Re,"run-log.json");function Wn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";
|
|
248
|
+
`)}`;try{await kt.addMessage(l,a)}catch(f){console.error(`[runReport] Failed to post end-of-session message: ${f.message}`)}}var Hn=Vn(import.meta.url),Jn=V.dirname(V.dirname(Hn)),Re=process.env.DATA_DIR?V.resolve(process.env.DATA_DIR,"collected-profiles"):V.join(Jn,"collected-profiles"),De=V.join(Re,"run-log.json");function Wn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";O.writeFileSync(o,n);for(let r=0;r<3;r++)try{O.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let l=Date.now();for(;Date.now()-l<200;);continue}throw s}}function xt(){try{if(!O.existsSync(De))return{runs:[]};let e=JSON.parse(O.readFileSync(De,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function $t(e){O.existsSync(Re)||O.mkdirSync(Re,{recursive:!0});try{Wn(De,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function Et(e,t="default"){let n=xt();for(let l of n.runs)l.status==="running"&&(l.status="interrupted",l.result="interrupted",l.timestamp&&(l.duration=Date.now()-new Date(l.timestamp).getTime()));let o=new Date,r={timestamp:o.toISOString(),script:e,mode:t,status:"running",result:null,duration:null,stats:null,error:null};n.runs.push(r);let s=Date.now()-30*24*60*60*1e3;return n.runs=n.runs.filter(l=>new Date(l.timestamp).getTime()>s),$t(n),{script:e,mode:t,startTime:o.getTime(),runIndex:n.runs.length-1}}function je(e,t,n=null,o=null){if(!e)return;let r=null;try{let l=xt(),i=l.runs[e.runIndex];if(i&&i.status==="running"&&i.script===e.script)i.status=t,i.result=t,i.duration=Date.now()-e.startTime,i.stats=n,i.error=o,r=i.duration;else{let a=l.runs.find(f=>f.script===e.script&&f.status==="running"&&f.timestamp===new Date(e.startTime).toISOString());a&&(a.status=t,a.result=t,a.duration=Date.now()-e.startTime,a.stats=n,a.error=o,r=a.duration)}$t(l)}catch(l){console.error(`[runLog] Failed to end run: ${l.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS){let l=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";Ct({scriptName:e.script,mode:e.mode,status:l,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(i=>console.error(`[runLog] postRunReport failed: ${i.message}`))}}import"dotenv/config";import*as u from"fs";import*as qe from"os";import*as S from"path";import{fileURLToPath as uo}from"url";var Le={};pe(Le,{NAME:()=>Yn,VERSION:()=>Gn,up:()=>Qn});import*as N from"fs";import*as he from"path";var Gn=1,Yn="normalize-jobs-and-questions",Kn=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],zn=50;function Oe(e){return N.existsSync(e)?JSON.parse(N.readFileSync(e,"utf-8")):null}function Ne(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{N.writeFileSync(o,n)}catch(r){try{N.unlinkSync(o)}catch{}throw r}try{N.renameSync(o,e)}catch(r){try{N.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Qn(e,t){let n=he.join(e,"jobs.json"),o=he.join(t,"scouted-jobs.json"),r=he.join(e,"application-questions.json"),s=Oe(n)||{},l=Oe(o)||{},i=0,a=[];for(let c of Object.keys(s)){if(!l[c])continue;let m=l[c],d=s[c];for(let p of Kn)m[p]!=null&&d[p]==null&&(d[p]=m[p]);a.push(c),i++}i>0?(Ne(n,s),console.log(` Phase 1: Merged ${i} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=Oe(r);if(f&&Array.isArray(f.applications)){let c={},m=0;for(let d of f.applications){let p=d.jobId||"unknown";c[p]||(c[p]={applications:[]});let v=(d.questions||[]).map(b=>{let E={type:b.type||"input",question:b.question||"",answer:b.answer||""};return b.options&&(b.options.length<=zn?E.options=b.options:(E.optionsOmitted=!0,m++)),b.page&&(E.page=b.page),b.wasPreFilled&&(E.wasPreFilled=!0),b.wasRetry&&(E.wasRetry=!0),E});c[p].applications.push({applicationId:d.applicationId,date:d.date,result:d.result||"submitted",formPages:d.formPages||null,duration:d.duration||null,retries:d.retries||0,failedField:d.failedField||null,questionCount:d.questionCount||v.length,questions:v})}Ne(r,c),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(c).length} unique jobs)`),m>0&&console.log(` Phase 2: Stripped bloated options from ${m} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(a.length>0){for(let c of a)delete l[c];Ne(o,l),console.log(` Phase 3: Removed ${a.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Fe={};pe(Fe,{NAME:()=>Xn,VERSION:()=>Zn,up:()=>no});import*as L from"fs";import*as At from"path";var Zn=2,Xn="reset-unread-flags";function eo(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function to(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{L.writeFileSync(o,n)}catch(r){try{L.unlinkSync(o)}catch{}throw r}try{L.renameSync(o,e)}catch(r){try{L.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function no(e){let t=At.join(e,"conversations.json"),n=eo(t);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let o=0;for(let r of Object.keys(n))n[r].unread===!0&&(n[r].unread=!1,o++);if(o===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}to(t,n),console.log(` Reset unread=false on ${o} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Me={};pe(Me,{NAME:()=>ro,VERSION:()=>oo,up:()=>co});import*as F from"fs";import*as _t from"path";var oo=3,ro="recompute-last-message-by",so=new Set(["draft","confirmed","rejected","needs_review"]);function io(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function lo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{F.writeFileSync(o,n)}catch(r){try{F.unlinkSync(o)}catch{}throw r}try{F.renameSync(o,e)}catch(r){try{F.unlinkSync(o)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function ao(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!so.has(s.status));if(n.length===0)return"them";let o=n.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,l)=>l.t-s.t).map(s=>s.m),r=o.length>0?o:[...n].reverse();for(let s of r){let l=s.sender;if(l===t)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function co(e){let t=_t.join(e,"conversations.json"),n=io(t);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let o=process.env.LINKEDIN_NAME;if(!o||typeof o!="string"||!o.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let r=0,s=0,l=0;for(let i of Object.keys(n)){let a=n[i];if(!a||typeof a!="object")continue;Object.prototype.hasOwnProperty.call(a,"_cardSynced")&&(delete a._cardSynced,s++);let f=Array.isArray(a.messages)?a.messages:[],c=ao(f,o),m=c==="me"?"awaiting_reply":"unanswered_by_us";a.lastMessageBy!==c&&l++,a.lastMessageBy=c,a.conversationStatus=m,r++}if(r===0){console.log(" No conversations to recompute.");return}lo(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${l} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var fo=uo(import.meta.url),mo=S.dirname(fo),po=S.dirname(S.dirname(mo));function ho(e){return e&&(e==="~"?qe.homedir():e.startsWith("~/")||e.startsWith("~\\")?S.join(qe.homedir(),e.slice(2)):e)}var M=process.env.DATA_DIR?S.resolve(ho(process.env.DATA_DIR)):po,X=S.join(M,"collected-profiles"),ee=S.join(M,"market-research"),R=S.join(M,".schema-version"),It=[S.join(X,".schema-version"),S.join(ee,".schema-version")],H=3,U=[{version:1,module:Le},{version:2,module:Fe},{version:3,module:Me}];(function(){U.sort((o,r)=>o.version-r.version);let t=new Set;for(let o of U){if(!Number.isInteger(o.version)||o.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(o.version)} (must be positive integer)`);if(t.has(o.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${o.version}`);t.add(o.version);let r=o.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${o.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==o.version)throw new Error(`MIGRATION_REGISTRY: v${o.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=U.length?U[U.length-1].version:0;if(n!==H)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${H}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let o=0;o<U.length;o++){let r=o+1;if(U[o].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${o} but found v${U[o].version}`)}})();function jt(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
249
249
|
[FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
|
|
250
250
|
`),process.exit(1));try{u.mkdirSync(M,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
|
|
251
251
|
[FATAL] Cannot create DATA_DIR (${M}): ${t.message}`),console.error(` Fix the path or permissions and try again.
|
|
@@ -267,7 +267,7 @@ ${o.join(`
|
|
|
267
267
|
[FATAL] ${R} is not valid JSON: ${n.message}`),console.error(" Refusing to proceed \u2014 silently treating it as 'fresh install' would re-apply"),console.error(" every migration on top of already-migrated data and corrupt it."),console.error(' Repair the file (set it to {"version":N,"migrations":[...]} matching your real state)'),console.error(` or restore from the *.pre-vNNN.backup files if you have them.
|
|
268
268
|
`),process.exit(1)}let t=bo(e);return t===null&&(console.error(`
|
|
269
269
|
[FATAL] ${R} has invalid structure:`),console.error(` ${JSON.stringify(e)?.slice(0,200)||"(unparseable)"}`),console.error(' Expected shape: { "version": <integer>, "migrations": [...] }'),console.error(` Repair the file or restore from a backup.
|
|
270
|
-
`),process.exit(1)),t}function
|
|
270
|
+
`),process.exit(1)),t}function Ot(e){try{u.chmodSync(e,384)}catch{}}function So(e){if(jt(),u.existsSync(R))try{if(u.lstatSync(R).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${R}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(n){if(n.message?.includes("symbolic link"))throw n}let t=R+".tmp";try{u.writeFileSync(t,JSON.stringify(e,null,2)),Ot(t),u.renameSync(t,R)}catch(n){try{u.unlinkSync(t)}catch{}throw n}}function Dt(e,t){if(!u.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=u.readdirSync(e).filter(i=>{let a=i.toLowerCase();if(a.includes(".backup")||a===".schema-version"||a.endsWith(".tmp"))return!1;try{return u.statSync(S.join(e,i)).isFile()}catch{return!1}}),r=0,s=0,l=[];for(let i of o){let a=S.join(e,i),f=S.join(e,i+n);if(u.existsSync(f)){s++;continue}try{Lt(a,f),r++}catch(c){l.push({file:i,err:c.message})}}if(l.length>0){let i=new Error(`Failed to back up ${l.length} file(s) in ${S.basename(e)}/: `+l.map(a=>`${a.file} (${a.err})`).join(", "));throw i.code="BACKUP_INCOMPLETE",i}if(r>0||s>0){let i=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${S.basename(e)}/ (${n})${i}`)}}var Pe=!1;async function Nt(){if(Pe)return;jt(),$o();let t=Rt().version;if(t===H){Pe=!0;return}yo(),go(),process.on("exit",Ue),t>H&&(console.error(`
|
|
271
271
|
[FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${H}.`),console.error(" This usually means you downgraded the plugin without rolling back data."),console.error(` Operating on the newer-format data with this build would risk corrupting it.
|
|
272
272
|
`),console.error(" Options:"),console.error(" A) Re-install the newer plugin version that produced this schema, then"),console.error(" (if you really want to downgrade) run 'rollback-data --confirm' first,"),console.error(" then re-install the older plugin version."),console.error(` B) Manually restore your data from the *.pre-vNNN.backup files matching v${H}.
|
|
273
273
|
`),process.exit(1)),console.log(`
|
|
@@ -285,7 +285,7 @@ ${o.join(`
|
|
|
285
285
|
[FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${a.message}`),console.error(` Your data is in the v${r.version} state but .schema-version still shows v${t}.`),console.error(` On next plugin command the runner will try to re-apply ${s}. If that migration is`),console.error(` idempotent (most are), it will succeed harmlessly. If you're unsure, run 'data-cleanup' and contact support.
|
|
286
286
|
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{dt()}catch{}try{yt()}catch{}Pe=!0,Ue(),console.log(`
|
|
287
287
|
\u2713 Schema is now at v${H}
|
|
288
|
-
`)}var vo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function ko(e){let t=e.toLowerCase();return vo.some(n=>n.test(t))}var Co=6e4;function xo(){let e=Date.now(),t=[];for(let n of[M,X,ee]){if(!u.existsSync(n))continue;let o;try{o=u.readdirSync(n)}catch{continue}for(let r of o){if(!ko(r))continue;let s=S.join(n,r);try{let l=u.statSync(s);if(!l.isFile()||e-l.mtimeMs<Co)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function $o({verbose:e=!1}={}){let t=xo();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{u.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${S.basename(o.dir)}/${o.file}`)}catch(r){console.warn(` [!] Could not remove orphan ${o.fullPath}: ${r.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Eo(){let e=[];for(let t of[X,ee]){if(!u.existsSync(t))continue;let n=u.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=S.join(t,o);try{ge(r)}catch(s){e.push({dir:S.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Ao(e){let t=[],n=[];for(let s of[X,ee]){if(!u.existsSync(s))continue;let l=u.readdirSync(s).filter(i=>i.endsWith(e));for(let i of l){let a=S.join(s,i),f=i.slice(0,-e.length),c=S.join(s,f);try{f.toLowerCase().endsWith(".json")?ge(a):u.accessSync(a,u.constants.R_OK),t.push({backupPath:a,originalPath:c,fileName:i,dir:s})}catch(m){n.push(`${S.basename(s)}/${i}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:l,fileName:i,dir:a}of t)try{Lt(s,l),o++}catch(f){r.push(`${S.basename(a)}/${i}: ${f.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Lt(e,t){let n=t+".tmp";try{u.copyFileSync(e,n),
|
|
288
|
+
`)}var vo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function ko(e){let t=e.toLowerCase();return vo.some(n=>n.test(t))}var Co=6e4;function xo(){let e=Date.now(),t=[];for(let n of[M,X,ee]){if(!u.existsSync(n))continue;let o;try{o=u.readdirSync(n)}catch{continue}for(let r of o){if(!ko(r))continue;let s=S.join(n,r);try{let l=u.statSync(s);if(!l.isFile()||e-l.mtimeMs<Co)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function $o({verbose:e=!1}={}){let t=xo();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{u.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${S.basename(o.dir)}/${o.file}`)}catch(r){console.warn(` [!] Could not remove orphan ${o.fullPath}: ${r.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Eo(){let e=[];for(let t of[X,ee]){if(!u.existsSync(t))continue;let n=u.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=S.join(t,o);try{ge(r)}catch(s){e.push({dir:S.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Ao(e){let t=[],n=[];for(let s of[X,ee]){if(!u.existsSync(s))continue;let l=u.readdirSync(s).filter(i=>i.endsWith(e));for(let i of l){let a=S.join(s,i),f=i.slice(0,-e.length),c=S.join(s,f);try{f.toLowerCase().endsWith(".json")?ge(a):u.accessSync(a,u.constants.R_OK),t.push({backupPath:a,originalPath:c,fileName:i,dir:s})}catch(m){n.push(`${S.basename(s)}/${i}: ${m.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:l,fileName:i,dir:a}of t)try{Lt(s,l),o++}catch(f){r.push(`${S.basename(a)}/${i}: ${f.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Lt(e,t){let n=t+".tmp";try{u.copyFileSync(e,n),Ot(n)}catch(o){try{u.unlinkSync(n)}catch{}throw o}try{u.renameSync(n,t)}catch(o){try{u.unlinkSync(n)}catch{}if(o.code==="EPERM"||o.code==="EBUSY"){let r=new Error(`File locked: ${t} (${o.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw r.code=o.code,r}throw o}}await Nt();var J=process.argv.slice(2),ye=parseInt(J.find(e=>e.startsWith("--max="))?.split("=")[1]||"10"),ue=J.includes("--connections"),Ft=J.find(e=>e.startsWith("--match-title="))?.split("=").slice(1).join("=")||null,_=Ft?Ro(Ft):null,_o=J.includes("--list"),Io=J.includes("--verbose"),Be=J.includes("--with-experience"),To=J.includes("--help")||J.includes("-h");To&&(console.log(`
|
|
289
289
|
enrich-profiles \u2014 batch-visit contacts in people.json missing About text
|
|
290
290
|
|
|
291
291
|
USAGE
|
|
@@ -328,12 +328,12 @@ WHEN TO USE
|
|
|
328
328
|
- You want to backfill in a controlled batch (\u2264 10 per day) before reaching
|
|
329
329
|
out, so AI drafting has full context.
|
|
330
330
|
- Use --connections to keep ban risk low.
|
|
331
|
-
`),process.exit(0));function Ro(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Do=new Set(["pending","sent_with_note","sent_without_note"]);function
|
|
331
|
+
`),process.exit(0));function Ro(e){try{return new RegExp(e,"i")}catch(t){console.error(`Invalid regex for --match-title: ${t.message}`),process.exit(1)}}var Do=new Set(["pending","sent_with_note","sent_without_note"]);function jo(e){return!e.about||!e.about.trim()}function Oo(e){return!Do.has(e.connectionStatus)}function Mt(){let e=K(),t=_e(),n=new Set,o=new Set;for(let i of Object.values(t))i.profileUrl&&n.add(i.profileUrl),(i.unread===!0||i.actionNeeded==="reply"||i.situation==="needs_our_reply"||i.conversationStatus==="unanswered_by_us")&&i.profileUrl&&o.add(i.profileUrl);let s=Object.entries(e).filter(([i,a])=>i&&i.startsWith("http")).filter(([,i])=>jo(i)).filter(([,i])=>Oo(i)).filter(([i])=>!o.has(i)).map(([i,a])=>({profileUrl:i,name:a.name,person:a,hasConversation:n.has(i)}));ue&&(s=s.filter(i=>i.person.connectionStatus==="connected")),_&&(s=s.filter(i=>_.test(i.person.title||"")));function l(i){let a=i.person.connectionStatus==="connected";return a&&i.hasConversation?1:a?2:_&&_.test(i.person.title||"")?3:i.hasConversation?4:5}return s.sort((i,a)=>{let f=l(i),c=l(a);if(f!==c)return f-c;let m=i.person.lastFullVisitAt||"",d=a.person.lastFullVisitAt||"";return m.localeCompare(d)}),s.map(i=>({profileUrl:i.profileUrl,name:i.name,source:"enrich-profile"}))}function No(){let e=K(),t=Object.keys(e).length,n=Object.values(e).filter(m=>m.about&&m.about.trim()).length,o=t-n,r=Mt(),s={connWithConv:0,conn:0,titleMatch:0,withConv:0,other:0},l=e,i=_e(),a=new Set(Object.values(i).map(m=>m.profileUrl).filter(Boolean)),f=Object.values(i).filter(m=>m.profileUrl&&(m.unread===!0||m.actionNeeded==="reply"||m.situation==="needs_our_reply"||m.conversationStatus==="unanswered_by_us")).length,c=0;for(let m of r){let d=l[m.profileUrl],p=d.connectionStatus==="connected",v=_&&_.test(d.title||""),b=a.has(m.profileUrl);d.lastFullVisitAt||c++,p&&b?s.connWithConv++:p?s.conn++:v?s.titleMatch++:b?s.withConv++:s.other++}console.log(`
|
|
332
332
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.log(" PROFILE ENRICHMENT QUEUE"),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(` Total people: ${t}`),console.log(` With "about": ${n} (${(n/t*100).toFixed(1)}%)`),console.log(` Missing "about": ${o}`),console.log(` Skipped (needs reply): ${f}`),console.log(` Visitable (queue): ${r.length}`),console.log(` Never fully visited: ${c} (gone first)`),_&&console.log(` Title-match filter: /${_.source}/i`),ue&&console.log(" Connections-only: yes"),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(` Tier 1 (conn+conv): ${s.connWithConv}`),console.log(` Tier 2 (connection): ${s.conn}`),console.log(` Tier 3 (title match): ${s.titleMatch}${_?"":" (no --match-title set)"}`),console.log(` Tier 4 (conversation): ${s.withConv}`),console.log(` Tier 5 (other): ${s.other}`),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(` At ${ye}/day \u2192 ~${Math.ceil(r.length/ye)} days to clear queue
|
|
333
333
|
`)}function Lo(){console.log(""),console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),console.log(" \u2551 \u26A0 BAN-RISK WARNING \u2014 please read \u2551"),console.log(" \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),console.log(" \u2551 This script visits LinkedIn profiles WITHOUT performing any \u2551"),console.log(" \u2551 follow-up action (no message, no connect request, no like). \u2551"),console.log(" \u2551 LinkedIn has previously flagged accounts for exactly this \u2551"),console.log(' \u2551 pattern with a "we noticed unusual activity" warning. \u2551'),console.log(" \u2551 \u2551"),console.log(" \u2551 Safer alternative: let data accumulate organically through \u2551"),console.log(" \u2551 apply / outreach / funnel / visit \u2014 those visits HAVE a \u2551"),console.log(" \u2551 purpose and don't trip the same heuristic. \u2551"),console.log(" \u2551 \u2551"),console.log(" \u2551 If you proceed, keep --max small (\u226410) and run at most once \u2551"),console.log(" \u2551 per day. Your account, your call. \u2551"),console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),console.log("")}async function Fo(){if(console.log(`
|
|
334
334
|
LinkedIn Profile Enricher
|
|
335
335
|
`),_o){No();return}Lo(),Be&&(console.log(""),console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),console.log(" \u2551 \u26A0 --with-experience: extra ban-risk warning \u2551"),console.log(" \u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"),console.log(" \u2551 Each visit now does TWO page loads (main + /details/ \u2551"),console.log(" \u2551 experience/). That doubles LinkedIn's view-counter signal \u2551"),console.log(" \u2551 per profile. Keep --max low (\u226410) and run rarely. \u2551"),console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),console.log(""));let e=Mt();if(console.log(` Queue size: ${e.length}`),console.log(` Max visits this session: ${ye}`),_&&console.log(` Title filter: /${_.source}/i`),ue&&console.log(" Connections only: yes"),Be&&console.log(" With experience: yes (2\xD7 page loads per profile)"),console.log(""),e.length===0){console.log(` Nothing to enrich \u2014 every visitable profile already has "about".
|
|
336
336
|
`);return}let t=ue&&_?"connections+title":ue?"connections":_?`title=${_.source}`:"all",n=Et("enrich-profiles",t),{browser:o,page:r}=await lt();try{let s=await St(r,e,{maxVisits:ye,verbose:Io,skipRecentDays:7,extractExperience:Be}),l=K(),i=0;for(let a of e.slice(0,s.visited+s.skipped))l[a.profileUrl]?.about?.trim()&&i++;console.log(`
|
|
337
337
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.log(" Enrichment Complete"),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(` Visited: ${s.visited}`),console.log(` Skipped (recent): ${s.skipped}`),console.log(` Errors: ${s.errors}`),console.log(` Have "about" now: ${i} / ${s.visited+s.skipped}`),console.log(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
338
|
-
`),
|
|
339
|
-
Error:`,s.message),
|
|
338
|
+
`),je(n,"success",s)}catch(s){console.error(`
|
|
339
|
+
Error:`,s.message),je(n,"error",null,s.message)}finally{await o.close().catch(()=>{})}}Fo().catch(e=>{console.error("Enrich-profiles failed:",e),process.exit(1)});
|