ilml-plugin-linkedin 1.13.0 → 1.13.1
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 +7 -1
- package/dist/enrichProfile.mjs +30 -5
- package/dist/enrichProfiles.mjs +41 -16
- package/dist/funnelRunner.mjs +40 -15
- package/dist/readPost.mjs +12 -6
- package/dist/run.mjs +39 -14
- package/dist/syncAll.mjs +57 -32
- package/dist/verifyAbout.mjs +28 -3
- package/dist/visit.mjs +36 -11
- package/ilml-plugin.json +1 -1
- package/package.json +1 -1
package/dist/verifyAbout.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ie=Object.defineProperty;var de=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{for(var o in t)Ie(e,o,{get:t[o],enumerable:!0})};async function d(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}async function me(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let n of t){let s=n.innerText||"",m=s.includes("Premium")||s.includes("premium")||s.includes("Upgrade")||s.includes("upgrade"),u=s.includes("Try for")||s.includes("free trial")||s.includes("/month")||s.includes("per month")||s.includes("Start my")||s.includes("Subscribe"),h=s.includes("Get hired faster")||s.includes("Get hired 2x");if(m||u||h){let D=n.querySelector('button[aria-label="Dismiss"]')||n.querySelector("button.artdeco-modal__dismiss")||n.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:s.substring(0,80)};let $=n.querySelectorAll("button");for(let l of $){let S=l.innerText?.trim().toLowerCase()||"",f=l.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||f.includes("dismiss"))return l.click(),{dismissed:!0,matched:s.substring(0,80)}}}}let o=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(o){let n=o.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||o.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(n)return n.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var j=de(()=>{});var we={};De(we,{extractCertificationsFromDetails:()=>Qe,extractEducationFromDetails:()=>Ge,extractExperienceFromDetails:()=>Ye,extractFeaturedFromDetails:()=>Ke,extractRecommendationsFromDetails:()=>Ze,extractSkillsFromDetails:()=>ze});async function Ye(e,t){let o=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let n=e.url();if(/\/(login|authwall|checkpoint)/i.test(n))throw new Error(`Session expired \u2014 bounced to ${n} when fetching /details/experience/`);for(let m=0;m<5;m++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(900);await d(1e3);let s=0;for(;s<5&&await e.evaluate(()=>{for(let u of document.querySelectorAll("button"))if(/^Load more$/i.test((u.textContent||"").trim()))return u.click(),!0;return!1});)s++,await d(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(700);return await e.evaluate(()=>{let m=document.querySelector("main");if(!m)return[];function u(l){let S=[];for(let f of l.querySelectorAll("div")){let p=Array.from(f.children).filter(x=>x.tagName==="DIV");if(p.length<3)continue;let w=p.filter(x=>(x.textContent||"").trim().length>50);w.length<3||(f.textContent||"").length<500||S.push({el:f,count:w.length,totalText:(f.textContent||"").length})}return S.sort((f,p)=>p.count-f.count||f.totalText-p.totalText),S[0]?.el}let h=u(m);if(!h)return[];let D=Array.from(h.children).filter(l=>l.tagName==="DIV").filter(l=>(l.textContent||"").trim().length>50);function $(l){let S=l[0]||null,f=null,p=null;if(l[1]){let a=l[1].split("\xB7").map(C=>C.trim());f=a[0]||null,a[1]&&(p=a[1])}let w=l.findIndex(a=>/(\d{4}|present)/i.test(a)&&/(-|–|—)/i.test(a)&&a.length<80),x=null,T=null;if(w>=0){let a=l[w].split("\xB7").map(C=>C.trim());x=a[0]||null,a[1]&&(T=a[1])}let M=null,J=-1;if(w>=0&&l[w+1]){let a=l[w+1],C=/^[>*\-•]|^>/.test(a),P=/https?:\/\//.test(a),
|
|
1
|
+
var Ie=Object.defineProperty;var de=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{for(var o in t)Ie(e,o,{get:t[o],enumerable:!0})};async function d(e){let t=Math.floor(Math.random()*2001),o=e+t;return new Promise(n=>setTimeout(n,o))}async function me(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let n of t){let s=n.innerText||"",m=s.includes("Premium")||s.includes("premium")||s.includes("Upgrade")||s.includes("upgrade"),u=s.includes("Try for")||s.includes("free trial")||s.includes("/month")||s.includes("per month")||s.includes("Start my")||s.includes("Subscribe"),h=s.includes("Get hired faster")||s.includes("Get hired 2x");if(m||u||h){let D=n.querySelector('button[aria-label="Dismiss"]')||n.querySelector("button.artdeco-modal__dismiss")||n.querySelector("button[data-test-modal-close-btn]");if(D)return D.click(),{dismissed:!0,matched:s.substring(0,80)};let $=n.querySelectorAll("button");for(let l of $){let S=l.innerText?.trim().toLowerCase()||"",f=l.getAttribute("aria-label")?.toLowerCase()||"";if(S==="not now"||S==="no thanks"||S==="dismiss"||f.includes("dismiss"))return l.click(),{dismissed:!0,matched:s.substring(0,80)}}}}let o=document.querySelector(".premium-upsell-link")||document.querySelector("[data-test-premium-upsell]")||document.querySelector(".premium-hub-upsell");if(o){let n=o.closest('[class*="modal"]')?.querySelector('button[aria-label="Dismiss"]')||o.closest('[class*="banner"]')?.querySelector('button[aria-label="Close"]');if(n)return n.click(),{dismissed:!0,matched:"premium-banner"}}return!1})}var j=de(()=>{});var we={};De(we,{extractCertificationsFromDetails:()=>Qe,extractEducationFromDetails:()=>Ge,extractExperienceFromDetails:()=>Ye,extractFeaturedFromDetails:()=>Ke,extractRecommendationsFromDetails:()=>Ze,extractSkillsFromDetails:()=>ze});async function Ye(e,t){let o=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let n=e.url();if(/\/(login|authwall|checkpoint)/i.test(n))throw new Error(`Session expired \u2014 bounced to ${n} when fetching /details/experience/`);for(let m=0;m<5;m++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(900);await d(1e3);let s=0;for(;s<5&&await e.evaluate(()=>{for(let u of document.querySelectorAll("button"))if(/^Load more$/i.test((u.textContent||"").trim()))return u.click(),!0;return!1});)s++,await d(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(700);return await e.evaluate(()=>{let m=document.querySelector("main");if(!m)return[];function u(l){let S=[];for(let f of l.querySelectorAll("div")){let p=Array.from(f.children).filter(x=>x.tagName==="DIV");if(p.length<3)continue;let w=p.filter(x=>(x.textContent||"").trim().length>50);w.length<3||(f.textContent||"").length<500||S.push({el:f,count:w.length,totalText:(f.textContent||"").length})}return S.sort((f,p)=>p.count-f.count||f.totalText-p.totalText),S[0]?.el}let h=u(m);if(!h)return[];let D=Array.from(h.children).filter(l=>l.tagName==="DIV").filter(l=>(l.textContent||"").trim().length>50);function $(l){let S=l[0]||null,f=null,p=null;if(l[1]){let a=l[1].split("\xB7").map(C=>C.trim());f=a[0]||null,a[1]&&(p=a[1])}let w=l.findIndex(a=>/(\d{4}|present)/i.test(a)&&/(-|–|—)/i.test(a)&&a.length<80),x=null,T=null;if(w>=0){let a=l[w].split("\xB7").map(C=>C.trim());x=a[0]||null,a[1]&&(T=a[1])}let M=null,J=-1;if(w>=0&&l[w+1]){let a=l[w+1],C=/^[>*\-•]|^>/.test(a),P=/https?:\/\//.test(a),v=/\d{4}/.test(a),H=/,/.test(a)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(a);!C&&!P&&!v&&a.length<100&&H&&(M=a,J=w+1)}let y=null,q=-1,E=l[l.length-1];if(E&&/and\s+\+\d+\s+skills?$/i.test(E)){q=l.length-1;let a=E.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);a&&(y={listed:a[1].split(",").map(C=>C.trim()),additional:parseInt(a[2],10)})}let L=new Set([0,1,w,J,q].filter(a=>a>=0)),k=l.filter((a,C)=>!L.has(C)),Y=k.length>0?k.join(`
|
|
2
2
|
|
|
3
3
|
`):null;return{title:S,company:f,employmentType:p,dates:x,duration:T,location:M,description:Y,skills:y,_raw:l}}return D.map(l=>{let f=(l.innerText||"").trim().split(`
|
|
4
4
|
`).map(p=>p.trim()).filter(p=>p&&p.length<5e3);return $(f)}).filter(l=>l.title)})}catch(n){if(/session expired|bounced to|authwall|checkpoint/i.test(n.message||""))throw n;return console.error(`extractExperienceFromDetails failed for ${t}: ${n.message?.slice(0,120)}`),[]}}async function O(e,t,o){let n=t.replace(/\/+$/,"")+`/details/${o}/`;await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let s=e.url();if(/\/(login|authwall|checkpoint)/i.test(s))throw new Error(`Session expired \u2014 bounced to ${s} when fetching /details/${o}/`);if(!s.toLowerCase().includes(`/details/${o.toLowerCase()}/`))throw new Error(`Section /details/${o}/ not available on profile (landed on ${s})`);for(let u=0;u<4;u++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(700);await d(800);let m=0;for(;m<5&&await e.evaluate(()=>{for(let h of document.querySelectorAll("button"))if(/^Load more$/i.test((h.textContent||"").trim()))return h.click(),!0;return!1});)m++,await d(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await d(600)}async function B(e,t,o,n){try{return await n()}catch(s){let m=s.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(m))throw s;return/not available on profile/i.test(m)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${o} failed for ${e}: ${m.slice(0,120)}`),[])}}async function Ke(e,t){return B(t,"featured","extractFeaturedFromDetails",async()=>(await O(e,t,"featured"),await e.evaluate(`(() => {
|
|
@@ -37,6 +37,9 @@ var Ie=Object.defineProperty;var de=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{
|
|
|
37
37
|
// Reject "People You May Know" sidebar cards: signature is
|
|
38
38
|
// exactly [title, "View"] with no url/caption beyond "View".
|
|
39
39
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
40
|
+
// Reject "Other profiles you may know" widget cards: caption is
|
|
41
|
+
// just a connection-degree marker (e.g. "\xB7 3rd", "\xB7 2nd").
|
|
42
|
+
if (e.caption && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.caption.trim())) return false;
|
|
40
43
|
return true;
|
|
41
44
|
});
|
|
42
45
|
})()`)))}async function Ge(e,t){return B(t,"education","extractEducationFromDetails",async()=>(await O(e,t,"education"),await e.evaluate(`(() => {
|
|
@@ -71,6 +74,9 @@ var Ie=Object.defineProperty;var de=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{
|
|
|
71
74
|
if (!e.school) return false;
|
|
72
75
|
// Reject "People You May Know" sidebar cards: [title, "View"].
|
|
73
76
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
77
|
+
// Reject related-profile widget: "degree" parsed as the
|
|
78
|
+
// connection-degree marker ("\xB7 3rd") instead of a real degree.
|
|
79
|
+
if (e.degree && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.degree.trim())) return false;
|
|
74
80
|
return true;
|
|
75
81
|
});
|
|
76
82
|
})()`)))}async function ze(e,t){return B(t,"skills","extractSkillsFromDetails",async()=>(await O(e,t,"skills"),await e.evaluate(`(() => {
|
|
@@ -161,6 +167,9 @@ var Ie=Object.defineProperty;var de=(e,t)=>()=>(e&&(t=e(e=0)),t);var De=(e,t)=>{
|
|
|
161
167
|
if (!e.recommender || !e.text) return false;
|
|
162
168
|
// Reject "People You May Know" sidebar cards: [title, "View"].
|
|
163
169
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
170
|
+
// Reject related-profile widget: recommenderTitle is the
|
|
171
|
+
// connection-degree marker, not a real job title.
|
|
172
|
+
if (e.recommenderTitle && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.recommenderTitle.trim())) return false;
|
|
164
173
|
return true;
|
|
165
174
|
});
|
|
166
175
|
})()`)))}var N,ye=de(()=>{j();N=`
|
|
@@ -183,6 +192,20 @@ function findEntryContainer(root) {
|
|
|
183
192
|
});
|
|
184
193
|
if (allLookLikePYMK) continue;
|
|
185
194
|
|
|
195
|
+
// Reject "Other profiles you may know" / related-profile widget:
|
|
196
|
+
// LinkedIn shows this when /details/<section>/ has no real data
|
|
197
|
+
// (e.g. profile has no Featured at all). Every entry is a short
|
|
198
|
+
// [name, "\xB7 Nth"] card with a connection-degree marker as the only
|
|
199
|
+
// metadata. Real Featured / Education / Recommendations entries
|
|
200
|
+
// NEVER consist solely of name + degree.
|
|
201
|
+
const DEGREE_RE = /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i;
|
|
202
|
+
const allLookLikeRelatedProfiles = substantial.every(c => {
|
|
203
|
+
const lines = (c.innerText || '').trim().split('\\n').map(l => l.trim()).filter(Boolean);
|
|
204
|
+
if (lines.length > 4) return false;
|
|
205
|
+
return lines.some(l => DEGREE_RE.test(l));
|
|
206
|
+
});
|
|
207
|
+
if (allLookLikeRelatedProfiles) continue;
|
|
208
|
+
|
|
186
209
|
// Reject LinkedIn footer/legal blocks: when a /details/<section>/ page
|
|
187
210
|
// renders empty, LinkedIn falls back to "Questions? Visit our Help
|
|
188
211
|
// Center", "Select language" (35+ languages), "Recommendation
|
|
@@ -198,6 +221,8 @@ function findEntryContainer(root) {
|
|
|
198
221
|
'Who your viewers also viewed', // "Private to you" PYMK block on empty pages
|
|
199
222
|
'People also viewed',
|
|
200
223
|
'People you may know',
|
|
224
|
+
'More profiles for you', // LinkedIn related-profiles widget shown
|
|
225
|
+
'Other profiles you may know', // when /details/<section>/ is empty
|
|
201
226
|
];
|
|
202
227
|
if (FOOTER_MARKERS.some(m => containerText.includes(m))) continue;
|
|
203
228
|
|
|
@@ -210,10 +235,10 @@ function findEntryContainer(root) {
|
|
|
210
235
|
candidates.sort((a, b) => b.count - a.count || b.totalText - a.totalText);
|
|
211
236
|
return candidates[0]?.el;
|
|
212
237
|
}
|
|
213
|
-
`});import je from"puppeteer";import{addExtra as Oe}from"puppeteer-extra";import Ne from"puppeteer-extra-plugin-stealth";j();import{getPluginConfig as Te}from"@ilivemylife/graph-sdk";var Me=await Te();for(let[e,t]of Object.entries(Me))process.env[e]===void 0&&(process.env[e]=t);var
|
|
238
|
+
`});import je from"puppeteer";import{addExtra as Oe}from"puppeteer-extra";import Ne from"puppeteer-extra-plugin-stealth";j();import{getPluginConfig as Te}from"@ilivemylife/graph-sdk";var Me=await Te();for(let[e,t]of Object.entries(Me))process.env[e]===void 0&&(process.env[e]=t);var Le=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])),Fe=Object.freeze(new Set([F.DRAFT,F.CONFIRMED,F.REJECTED,F.NEEDS_REVIEW]));import fe from"fs";import qe from"path";var Pe="cookies.json";function Re(){let e=process.env.ILML_SCOPE_DIR;return e?qe.join(e,"plugins-state","linkedin","cookies.json"):Pe}function pe(){let e=Re();if(!fe.existsSync(e))throw new Error(`Cookies not found at ${e}. Run: ilml linkedin login`);let t;try{t=fe.readFileSync(e,"utf-8")}catch(n){throw new Error(`Failed to read cookies at ${e}: ${n.message}. Run: ilml linkedin login`)}let o;try{o=JSON.parse(t)}catch{throw new Error(`Cookies file at ${e} is corrupted (invalid JSON). Run: ilml linkedin login`)}if(!Array.isArray(o)||o.length===0)throw new Error(`Cookies file at ${e} is empty or not an array. Run: ilml linkedin login`);return o}var he=Oe(je);he.use(Ne());async function ge(){let e=await he.launch({headless:!1,defaultViewport:null,protocolTimeout:3e5}),t=async()=>{console.log(`
|
|
214
239
|
Closing browser...`);try{await e.close()}catch{}process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t);let o=await e.newPage();await o.evaluateOnNewDocument(()=>{Object.defineProperty(navigator,"webdriver",{get:()=>{}})});try{let n=pe();await o.setCookie(...n),console.log(" Browser launched, cookies loaded.")}catch(n){console.error(`
|
|
215
240
|
[!] ${n.message}
|
|
216
|
-
`),await e.close(),process.exit(1)}return{browser:e,page:o}}j();import"dotenv/config";import*as g from"fs";import*as b from"path";import{fileURLToPath as Be}from"url";var He=Be(import.meta.url),Ue=b.dirname(b.dirname(He)),
|
|
241
|
+
`),await e.close(),process.exit(1)}return{browser:e,page:o}}j();import"dotenv/config";import*as g from"fs";import*as b from"path";import{fileURLToPath as Be}from"url";var He=Be(import.meta.url),Ue=b.dirname(b.dirname(He)),A=process.env.DATA_DIR?b.resolve(process.env.DATA_DIR,"collected-profiles"):b.join(Ue,"collected-profiles"),Ve=b.join(A,"people.json"),_t=b.join(A,"jobs.json"),Et=b.join(A,"quota.json"),At=b.join(A,"conversations.json"),$t=b.join(A,"sync-state.json"),It=b.join(A,"application-questions.json"),Dt=b.join(A,"profile-history");var W=null;function We(){g.existsSync(A)||g.mkdirSync(A,{recursive:!0})}function Je(e,t){if(!g.existsSync(e))return null;try{let o=JSON.parse(g.readFileSync(e,"utf-8"));try{g.copyFileSync(e,e+".backup")}catch{}return o}catch(o){console.error(`[!] ${t} is corrupted: ${o.message}`),console.error(` File: ${b.resolve(e)}`);let n=e+".backup";if(g.existsSync(n))try{let s=JSON.parse(g.readFileSync(n,"utf-8"));console.error(` Restored from ${n}`);try{g.copyFileSync(n,e)}catch{}return s}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{g.copyFileSync(e,e+".corrupted")}catch{}return null}}function z(){return W||(We(),W=Je(Ve,"people.json")||{},W)}async function Xe(e,t){let o=e.url();if(o.includes("/in/"))return!1;if(o.includes("/login")||o.includes("/authwall")||o.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${o.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3);let n=e.url();return n.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${n.slice(0,80)}`),!0}async function be(e,t,o={}){let{extractExperience:n=!1,extractFeatured:s=!1,extractEducation:m=!1,extractSkills:u=!1,extractRecommendations:h=!1,extractCertifications:D=!1}=o;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await d(3e3),await me(e)&&(console.log(" Dismissed Premium overlay"),await d(1500),await Xe(e,t));let l=0;for(let y=0;y<2;y++){let q=await e.evaluate(()=>document.body.scrollHeight);for(let L=1;L<=6;L++)await e.evaluate(k=>window.scrollTo(0,k),q*L/6),await d(900);let E=await e.evaluate(()=>document.body.scrollHeight);if(E===l)break;l=E}await d(800);let S=await e.evaluate(()=>{let y=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"]),q=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"]),E=i=>{let r=(i||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(r)},L={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:[]},k=document.querySelector("main");if(!k)return L;let Y=[...Array.from(k.querySelectorAll("h1")),...Array.from(k.querySelectorAll("h2"))],a=Array.from(k.querySelectorAll("h2")),C=Y.find(i=>{let r=i.textContent&&i.textContent.trim(),c=(r||"").replace(/\s*\(\d+\)$/,"").trim();return r&&r.length>1&&r.length<100&&!y.has(c)&&!q.has(c)}),P=C?C.textContent.trim():null,v=C?C.parentElement:null;for(;v&&v!==k&&!Array.from(v.children).filter(r=>r.tagName==="P").some(r=>{let c=r.textContent&&r.textContent.trim();return c&&c.length>5&&!E(c)});)v=v.parentElement;let H=null,Z=null,X=null,K=null;if(v&&v!==k){let i=Array.from(v.children).filter(c=>c.tagName==="P").filter(c=>{let I=c.textContent&&c.textContent.trim();return I&&I.length>5&&!E(I)});if(i[0]&&(H=i[0].textContent.trim()),i[1]){let c=i[1].textContent.trim().split(/\s*[·•]\s*/);Z=c[0]||null,c.length>1&&(X=c.slice(1).join(" \xB7 "))}let r=Array.from(v.children).filter(c=>c.tagName==="DIV");for(let c=r.length-1;c>=0;c--){let I=r[c].textContent&&r[c].textContent.trim();if(I&&!(P&&I.startsWith(P))&&(K=I.split(/[·•]/)[0].trim(),K))break}}let ee=null;if(v){let i=v.querySelectorAll("p, span, div");for(let r of i){let c=(r.textContent||"").trim().replace(/^[·•]\s*/,"");if(c==="1st"||c==="2nd"||c==="3rd"){ee=c;break}}}let ke=!!k.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),te=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),ve=te&&te.src||null,U=k.textContent||"",ne=null,oe=U.match(/(\d+\+?)\s+connections\b/i);oe&&(ne=oe[1]+" connections");let V=null,ie=U.match(/(\d+)\s+mutual connection/i),se=U.match(/and\s+(\d+)\s+other mutual/i),xe=U.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);ie?V=parseInt(ie[1],10):se?V=2+parseInt(se[1],10):xe&&(V=2);let re=null,le=null,ae=a.find(i=>i.textContent&&i.textContent.trim()==="About");if(ae){let i=ae.parentElement;for(;i&&i.tagName!=="SECTION";)i=i.parentElement;if(i){let r=(i.textContent||"").trim();r=r.replace(/^About\s*/,"").trim();let c=r.match(/Top skills\s*(.+?)$/i);if(c){let G=c[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map($e=>$e.trim()).filter(Boolean);G.length>0&&G.length<10&&(le=G)}r=r.split(/\n?…\s*more/i)[0].trim(),r=r.split(/\n?\.\.\.\s*more/i)[0].trim(),r=r.split(/\bTop skills\b/i)[0].trim(),r=r.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),re=r||null}}let ce=null,ue=a.find(i=>i.textContent&&i.textContent.trim()==="Activity");if(ue){let i=ue.parentElement;for(;i&&i.tagName!=="SECTION";)i=i.parentElement;if(i){let r=(i.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);r&&(ce=parseInt(r[1].replace(/,/g,""),10))}}let _e=[...new Set(a.map(i=>(i.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(i=>i&&i.length>1&&i.length<60&&i!==P).filter(i=>y.has(i)))],R=document.body.textContent||"",Ee=/#OpenToWork\b/i.test(R)||/\bOpen to work\b/.test(R),Ae=/#Hiring\b/i.test(R)||/\bI'?m hiring\b/i.test(R)||/\bWe are hiring\b/i.test(R);return{name:P,title:H,location:K,currentCompany:Z,currentSchool:X,connectionDegree:ee,hasVerifiedBadge:ke,photoUrl:ve,connectionsLevel:ne,mutualConnectionsCount:V,followers:ce,openToWork:Ee,hiring:Ae,about:re,topSkills:le,availableSections:_e}});console.log(`Viewed: ${S.name} - ${S.title}`);let f=null,p=null,w=null,x=null,T=null,M=null;if(n||s||m||u||h||D){let y=await Promise.resolve().then(()=>(ye(),we));n&&(f=await y.extractExperienceFromDetails(e,t),console.log(` + Experience: ${f.length} entries`)),s&&(p=await y.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${p.length} entries`)),m&&(w=await y.extractEducationFromDetails(e,t),console.log(` + Education: ${w.length} entries`)),u&&(x=await y.extractSkillsFromDetails(e,t),console.log(` + Skills: ${x.length} entries`)),h&&(T=await y.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${T.length} entries`)),D&&(M=await y.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${M.length} entries`))}return{...S,profileUrl:t,...f!==null&&{experience:f},...p!==null&&{featured:p},...w!==null&&{education:w},...x!==null&&{skillsFull:x},...T!==null&&{recommendations:T},...M!==null&&{certifications:M}}}catch($){console.error(`Error viewing profile ${t}:`,$.message);try{await e.goto("about:blank",{timeout:1e4}),await d(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test($.message||""))throw $;return null}}j();var Q=process.argv.slice(2),Se=Q.filter(e=>e.startsWith("http")),Ce=parseInt(Q.find(e=>e.startsWith("--pick="))?.split("=")[1]||"0"),et=Q.includes("--has-about");function tt(e,t){return[...e].sort(()=>Math.random()-.5).slice(0,t)}function nt(){if(Se.length>0)return Se.map(t=>({url:t,name:"(arg)"}));if(Ce>0){let t=z(),o=Object.entries(t).filter(([n])=>n.startsWith("http")).filter(([,n])=>et?!!(n.about&&n.about.trim()):!n.about);return tt(o,Ce).map(([n,s])=>({url:n,name:s.name}))}let e=process.env.MY_LINKEDIN_URL;return e||(console.error("Pass a URL, use --pick=N, or set MY_LINKEDIN_URL in .env"),process.exit(1)),[{url:e,name:"(self)"}]}function _(e,t,o=80){if(t==null){console.log(` ${e.padEnd(20)} (null)`);return}let n=String(t),s=n.length>o?n.slice(0,o)+`\u2026 (+${n.length-o} chars)`:n;console.log(` ${e.padEnd(20)} ${s} [len=${n.length}]`)}async function ot(){let e=nt();console.log(`
|
|
217
242
|
About-selector verification \u2014 ${e.length} profile(s)
|
|
218
243
|
`);let{browser:t,page:o}=await ge();try{for(let n=0;n<e.length;n++){let{url:s,name:m}=e[n];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(` [${n+1}/${e.length}] ${m}`),console.log(` ${s}`),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");let u=await be(o,s);if(!u){console.log(` \u26A0 viewProfile returned null \u2014 selector failed entirely
|
|
219
244
|
`);continue}_("name",u.name),_("title",u.title),_("location",u.location),_("company",u.company),_("connectionDegree",u.connectionDegree),_("connectionsCount",u.connectionsCount),_("mutualConnections",u.mutualConnections),_("hasVerifiedBadge",u.hasVerifiedBadge),_("photoUrl",u.photoUrl,60),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 about \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),_("about",u.about,200);let h=[];u.name||h.push("NAME MISSING"),u.title||h.push("TITLE MISSING"),u.location||h.push("LOCATION MISSING"),u.about||h.push("ABOUT MISSING"),console.log(`
|
package/dist/visit.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Kt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{for(var n in t)Kt(e,n,{get:t[n],enumerable:!0})};async function $(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function ot(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of t){let r=o.innerText||"",s=r.includes("Premium")||r.includes("premium")||r.includes("Upgrade")||r.includes("upgrade"),i=r.includes("Try for")||r.includes("free trial")||r.includes("/month")||r.includes("per month")||r.includes("Start my")||r.includes("Subscribe"),c=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||c){let a=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(a)return a.click(),{dismissed:!0,matched:r.substring(0,80)};let m=o.querySelectorAll("button");for(let l of m){let y=l.innerText?.trim().toLowerCase()||"",u=l.getAttribute("aria-label")?.toLowerCase()||"";if(y==="not now"||y==="no thanks"||y==="dismiss"||u.includes("dismiss"))return l.click(),{dismissed:!0,matched:r.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 se=nt(()=>{});var ht={};ge(ht,{extractCertificationsFromDetails:()=>_n,extractEducationFromDetails:()=>
|
|
1
|
+
var Kt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{for(var n in t)Kt(e,n,{get:t[n],enumerable:!0})};async function $(e){let t=Math.floor(Math.random()*2001),n=e+t;return new Promise(o=>setTimeout(o,n))}async function ot(e){return await e.evaluate(()=>{let t=document.querySelectorAll("div.artdeco-modal--is-open");for(let o of t){let r=o.innerText||"",s=r.includes("Premium")||r.includes("premium")||r.includes("Upgrade")||r.includes("upgrade"),i=r.includes("Try for")||r.includes("free trial")||r.includes("/month")||r.includes("per month")||r.includes("Start my")||r.includes("Subscribe"),c=r.includes("Get hired faster")||r.includes("Get hired 2x");if(s||i||c){let a=o.querySelector('button[aria-label="Dismiss"]')||o.querySelector("button.artdeco-modal__dismiss")||o.querySelector("button[data-test-modal-close-btn]");if(a)return a.click(),{dismissed:!0,matched:r.substring(0,80)};let m=o.querySelectorAll("button");for(let l of m){let y=l.innerText?.trim().toLowerCase()||"",u=l.getAttribute("aria-label")?.toLowerCase()||"";if(y==="not now"||y==="no thanks"||y==="dismiss"||u.includes("dismiss"))return l.click(),{dismissed:!0,matched:r.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 se=nt(()=>{});var ht={};ge(ht,{extractCertificationsFromDetails:()=>_n,extractEducationFromDetails:()=>En,extractExperienceFromDetails:()=>xn,extractFeaturedFromDetails:()=>$n,extractRecommendationsFromDetails:()=>In,extractSkillsFromDetails:()=>An});async function xn(e,t){let n=t.replace(/\/+$/,"")+"/details/experience/";try{await e.goto(n,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let o=e.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 e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await $(900);await $(1e3);let r=0;for(;r<5&&await e.evaluate(()=>{for(let i of document.querySelectorAll("button"))if(/^Load more$/i.test((i.textContent||"").trim()))return i.click(),!0;return!1});)r++,await $(1500),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await $(700);return await e.evaluate(()=>{let s=document.querySelector("main");if(!s)return[];function i(l){let y=[];for(let u of l.querySelectorAll("div")){let f=Array.from(u.children).filter(v=>v.tagName==="DIV");if(f.length<3)continue;let C=f.filter(v=>(v.textContent||"").trim().length>50);C.length<3||(u.textContent||"").length<500||y.push({el:u,count:C.length,totalText:(u.textContent||"").length})}return y.sort((u,f)=>f.count-u.count||u.totalText-f.totalText),y[0]?.el}let c=i(s);if(!c)return[];let a=Array.from(c.children).filter(l=>l.tagName==="DIV").filter(l=>(l.textContent||"").trim().length>50);function m(l){let y=l[0]||null,u=null,f=null;if(l[1]){let b=l[1].split("\xB7").map(I=>I.trim());u=b[0]||null,b[1]&&(f=b[1])}let C=l.findIndex(b=>/(\d{4}|present)/i.test(b)&&/(-|–|—)/i.test(b)&&b.length<80),v=null,_=null;if(C>=0){let b=l[C].split("\xB7").map(I=>I.trim());v=b[0]||null,b[1]&&(_=b[1])}let h=null,g=-1;if(C>=0&&l[C+1]){let b=l[C+1],I=/^[>*\-•]|^>/.test(b),te=/https?:\/\//.test(b),D=/\d{4}/.test(b),me=/,/.test(b)||/\bArea\b|\bRegion\b|\bProvince\b|\bCountry\b|, [A-Z]{2}\b/.test(b);!I&&!te&&!D&&b.length<100&&me&&(h=b,g=C+1)}let x=null,ee=-1,q=l[l.length-1];if(q&&/and\s+\+\d+\s+skills?$/i.test(q)){ee=l.length-1;let b=q.match(/^(.+?)\s+and\s+\+(\d+)\s+skills?$/i);b&&(x={listed:b[1].split(",").map(I=>I.trim()),additional:parseInt(b[2],10)})}let W=new Set([0,1,C,g,ee].filter(b=>b>=0)),T=l.filter((b,I)=>!W.has(I)),ve=T.length>0?T.join(`
|
|
2
2
|
|
|
3
3
|
`):null;return{title:y,company:u,employmentType:f,dates:v,duration:_,location:h,description:ve,skills:x,_raw:l}}return a.map(l=>{let u=(l.innerText||"").trim().split(`
|
|
4
4
|
`).map(f=>f.trim()).filter(f=>f&&f.length<5e3);return m(u)}).filter(l=>l.title)})}catch(o){if(/session expired|bounced to|authwall|checkpoint/i.test(o.message||""))throw o;return console.error(`extractExperienceFromDetails failed for ${t}: ${o.message?.slice(0,120)}`),[]}}async function le(e,t,n){let o=t.replace(/\/+$/,"")+`/details/${n}/`;await e.goto(o,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let r=e.url();if(/\/(login|authwall|checkpoint)/i.test(r))throw new Error(`Session expired \u2014 bounced to ${r} when fetching /details/${n}/`);if(!r.toLowerCase().includes(`/details/${n.toLowerCase()}/`))throw new Error(`Section /details/${n}/ not available on profile (landed on ${r})`);for(let i=0;i<4;i++)await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await $(700);await $(800);let s=0;for(;s<5&&await e.evaluate(()=>{for(let c of document.querySelectorAll("button"))if(/^Load more$/i.test((c.textContent||"").trim()))return c.click(),!0;return!1});)s++,await $(1300),await e.evaluate(()=>window.scrollTo(0,document.body.scrollHeight)),await $(600)}async function ce(e,t,n,o){try{return await o()}catch(r){let s=r.message||"";if(/session expired|bounced to|authwall|checkpoint/i.test(s))throw r;return/not available on profile/i.test(s)?(console.log(` (${t}: section not on profile \u2014 skipped)`),[]):(console.error(`${n} failed for ${e}: ${s.slice(0,120)}`),[])}}async function $n(e,t){return ce(t,"featured","extractFeaturedFromDetails",async()=>(await le(e,t,"featured"),await e.evaluate(`(() => {
|
|
@@ -37,9 +37,12 @@ var Kt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{
|
|
|
37
37
|
// Reject "People You May Know" sidebar cards: signature is
|
|
38
38
|
// exactly [title, "View"] with no url/caption beyond "View".
|
|
39
39
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
40
|
+
// Reject "Other profiles you may know" widget cards: caption is
|
|
41
|
+
// just a connection-degree marker (e.g. "\xB7 3rd", "\xB7 2nd").
|
|
42
|
+
if (e.caption && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.caption.trim())) return false;
|
|
40
43
|
return true;
|
|
41
44
|
});
|
|
42
|
-
})()`)))}async function
|
|
45
|
+
})()`)))}async function En(e,t){return ce(t,"education","extractEducationFromDetails",async()=>(await le(e,t,"education"),await e.evaluate(`(() => {
|
|
43
46
|
${ae}
|
|
44
47
|
|
|
45
48
|
const main = document.querySelector('main');
|
|
@@ -71,9 +74,12 @@ var Kt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{
|
|
|
71
74
|
if (!e.school) return false;
|
|
72
75
|
// Reject "People You May Know" sidebar cards: [title, "View"].
|
|
73
76
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
77
|
+
// Reject related-profile widget: "degree" parsed as the
|
|
78
|
+
// connection-degree marker ("\xB7 3rd") instead of a real degree.
|
|
79
|
+
if (e.degree && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.degree.trim())) return false;
|
|
74
80
|
return true;
|
|
75
81
|
});
|
|
76
|
-
})()`)))}async function
|
|
82
|
+
})()`)))}async function An(e,t){return ce(t,"skills","extractSkillsFromDetails",async()=>(await le(e,t,"skills"),await e.evaluate(`(() => {
|
|
77
83
|
${ae}
|
|
78
84
|
|
|
79
85
|
const main = document.querySelector('main');
|
|
@@ -161,6 +167,9 @@ var Kt=Object.defineProperty;var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var ge=(e,t)=>{
|
|
|
161
167
|
if (!e.recommender || !e.text) return false;
|
|
162
168
|
// Reject "People You May Know" sidebar cards: [title, "View"].
|
|
163
169
|
if (e._raw.length === 2 && e._raw[1] === 'View') return false;
|
|
170
|
+
// Reject related-profile widget: recommenderTitle is the
|
|
171
|
+
// connection-degree marker, not a real job title.
|
|
172
|
+
if (e.recommenderTitle && /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i.test(e.recommenderTitle.trim())) return false;
|
|
164
173
|
return true;
|
|
165
174
|
});
|
|
166
175
|
})()`)))}var ae,gt=nt(()=>{se();ae=`
|
|
@@ -183,6 +192,20 @@ function findEntryContainer(root) {
|
|
|
183
192
|
});
|
|
184
193
|
if (allLookLikePYMK) continue;
|
|
185
194
|
|
|
195
|
+
// Reject "Other profiles you may know" / related-profile widget:
|
|
196
|
+
// LinkedIn shows this when /details/<section>/ has no real data
|
|
197
|
+
// (e.g. profile has no Featured at all). Every entry is a short
|
|
198
|
+
// [name, "\xB7 Nth"] card with a connection-degree marker as the only
|
|
199
|
+
// metadata. Real Featured / Education / Recommendations entries
|
|
200
|
+
// NEVER consist solely of name + degree.
|
|
201
|
+
const DEGREE_RE = /^\xB7\\s*\\d+(?:st|nd|rd|th)\\+?$/i;
|
|
202
|
+
const allLookLikeRelatedProfiles = substantial.every(c => {
|
|
203
|
+
const lines = (c.innerText || '').trim().split('\\n').map(l => l.trim()).filter(Boolean);
|
|
204
|
+
if (lines.length > 4) return false;
|
|
205
|
+
return lines.some(l => DEGREE_RE.test(l));
|
|
206
|
+
});
|
|
207
|
+
if (allLookLikeRelatedProfiles) continue;
|
|
208
|
+
|
|
186
209
|
// Reject LinkedIn footer/legal blocks: when a /details/<section>/ page
|
|
187
210
|
// renders empty, LinkedIn falls back to "Questions? Visit our Help
|
|
188
211
|
// Center", "Select language" (35+ languages), "Recommendation
|
|
@@ -198,6 +221,8 @@ function findEntryContainer(root) {
|
|
|
198
221
|
'Who your viewers also viewed', // "Private to you" PYMK block on empty pages
|
|
199
222
|
'People also viewed',
|
|
200
223
|
'People you may know',
|
|
224
|
+
'More profiles for you', // LinkedIn related-profiles widget shown
|
|
225
|
+
'Other profiles you may know', // when /details/<section>/ is empty
|
|
201
226
|
];
|
|
202
227
|
if (FOOTER_MARKERS.some(m => containerText.includes(m))) continue;
|
|
203
228
|
|
|
@@ -213,14 +238,14 @@ function findEntryContainer(root) {
|
|
|
213
238
|
`});import on from"puppeteer";import{addExtra as rn}from"puppeteer-extra";import sn from"puppeteer-extra-plugin-stealth";se();import{getPluginConfig as zt}from"@ilivemylife/graph-sdk";var Qt=await zt();for(let[e,t]of Object.entries(Qt))process.env[e]===void 0&&(process.env[e]=t);var Zt=process.env.LINKEDIN_NAME,Y=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Mo=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.NEEDS_REVIEW])),Xt=Object.freeze(new Set([Y.DRAFT,Y.CONFIRMED,Y.REJECTED,Y.NEEDS_REVIEW]));import rt from"fs";import en from"path";var tn="cookies.json";function nn(){let e=process.env.ILML_SCOPE_DIR;return e?en.join(e,"plugins-state","linkedin","cookies.json"):tn}function st(){let e=nn();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=rn(on);it.use(sn());async function lt(){let e=await it.launch({headless:!1,defaultViewport:null,protocolTimeout:3e5}),t=async()=>{console.log(`
|
|
214
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(`
|
|
215
240
|
[!] ${o.message}
|
|
216
|
-
`),await e.close(),process.exit(1)}return{browser:e,page:n}}se();import"dotenv/config";import*as A from"fs";import*as E from"path";import{fileURLToPath as ln}from"url";var an=ln(import.meta.url),cn=E.dirname(E.dirname(an)),B=process.env.DATA_DIR?E.resolve(process.env.DATA_DIR,"collected-profiles"):E.join(cn,"collected-profiles"),xe=E.join(B,"people.json"),nr=E.join(B,"jobs.json"),or=E.join(B,"quota.json"),rr=E.join(B,"conversations.json"),sr=E.join(B,"sync-state.json"),ir=E.join(B,"application-questions.json"),$e=E.join(B,"profile-history");var ne=null,un=null,dn=null,fn=null,mn=null,pn=null;function ut(){ne=null,un=null,dn=null,fn=null,mn=null,pn=null}function dt(){A.existsSync(B)||A.mkdirSync(B,{recursive:!0})}function ft(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";A.writeFileSync(o,n);for(let r=0;r<3;r++)try{A.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function mt(e,t){if(!A.existsSync(e))return null;try{let n=JSON.parse(A.readFileSync(e,"utf-8"));try{A.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${E.resolve(e)}`);let o=e+".backup";if(A.existsSync(o))try{let r=JSON.parse(A.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{A.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{A.copyFileSync(e,e+".corrupted")}catch{}return null}}function hn(){return new Date().toISOString().split("T")[0]}var gn=["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"],yn=["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 wn(){A.existsSync($e)||A.mkdirSync($e,{recursive:!0})}function pt(e){let t=Ae(e);return t?E.join($e,`${t}.json`):null}function bn(e){let t=pt(e);return t?mt(t,`profile-history/${Ae(e)}.json`)||[]:[]}function Sn(e,t){let n=pt(e);if(!n)return;wn();let o=bn(e);o.unshift(t);try{ft(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 vn(e,t){if(!e)return[];let n=[];for(let o of yn){let r=e[o],s=t[o];at(r)||at(s)||ct(r)!==ct(s)&&n.push(o)}return n}function kn(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 ie(){return ne||(dt(),ne=mt(xe,"people.json")||{},ne)}function Cn(e){dt(),ne=e;try{ft(xe,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${E.resolve(xe)}`)}}function Ee(e,t={}){if(!e)return null;let n=ie(),o=hn(),r=new Date().toISOString(),s=n[e];if(s){let i=vn(s,t);i.length>0&&(Sn(e,{capturedAt:r,previousLastUpdated:s.lastUpdated||null,changedFields:i,snapshot:kn(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 c of gn)if(t[c]!=null){if(Array.isArray(t[c])&&t[c].length===0&&Array.isArray(s[c])&&s[c].length>0)continue;s[c]=t[c]}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 Cn(n),n[e]}async function Tn(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function yt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:c=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await $(1500),await Tn(e,t));let l=0;for(let x=0;x<2;x++){let ee=await e.evaluate(()=>document.body.scrollHeight);for(let W=1;W<=6;W++)await e.evaluate(T=>window.scrollTo(0,T),ee*W/6),await $(900);let q=await e.evaluate(()=>document.body.scrollHeight);if(q===l)break;l=q}await $(800);let y=await e.evaluate(()=>{let x=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"]),ee=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"]),q=p=>{let w=(p||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(w)},W={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:[]},T=document.querySelector("main");if(!T)return W;let ve=[...Array.from(T.querySelectorAll("h1")),...Array.from(T.querySelectorAll("h2"))],b=Array.from(T.querySelectorAll("h2")),I=ve.find(p=>{let w=p.textContent&&p.textContent.trim(),S=(w||"").replace(/\s*\(\d+\)$/,"").trim();return w&&w.length>1&&w.length<100&&!x.has(S)&&!ee.has(S)}),te=I?I.textContent.trim():null,D=I?I.parentElement:null;for(;D&&D!==T&&!Array.from(D.children).filter(w=>w.tagName==="P").some(w=>{let S=w.textContent&&w.textContent.trim();return S&&S.length>5&&!q(S)});)D=D.parentElement;let me=null,Ve=null,He=null,ke=null;if(D&&D!==T){let p=Array.from(D.children).filter(S=>S.tagName==="P").filter(S=>{let V=S.textContent&&S.textContent.trim();return V&&V.length>5&&!q(V)});if(p[0]&&(me=p[0].textContent.trim()),p[1]){let S=p[1].textContent.trim().split(/\s*[·•]\s*/);Ve=S[0]||null,S.length>1&&(He=S.slice(1).join(" \xB7 "))}let w=Array.from(D.children).filter(S=>S.tagName==="DIV");for(let S=w.length-1;S>=0;S--){let V=w[S].textContent&&w[S].textContent.trim();if(V&&!(te&&V.startsWith(te))&&(ke=V.split(/[·•]/)[0].trim(),ke))break}}let Je=null;if(D){let p=D.querySelectorAll("p, span, div");for(let w of p){let S=(w.textContent||"").trim().replace(/^[·•]\s*/,"");if(S==="1st"||S==="2nd"||S==="3rd"){Je=S;break}}}let Ut=!!T.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),We=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Vt=We&&We.src||null,pe=T.textContent||"",Ye=null,Ge=pe.match(/(\d+\+?)\s+connections\b/i);Ge&&(Ye=Ge[1]+" connections");let he=null,Ke=pe.match(/(\d+)\s+mutual connection/i),ze=pe.match(/and\s+(\d+)\s+other mutual/i),Ht=pe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?he=parseInt(Ke[1],10):ze?he=2+parseInt(ze[1],10):Ht&&(he=2);let Qe=null,Ze=null,Xe=b.find(p=>p.textContent&&p.textContent.trim()==="About");if(Xe){let p=Xe.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let w=(p.textContent||"").trim();w=w.replace(/^About\s*/,"").trim();let S=w.match(/Top skills\s*(.+?)$/i);if(S){let Ce=S[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Gt=>Gt.trim()).filter(Boolean);Ce.length>0&&Ce.length<10&&(Ze=Ce)}w=w.split(/\n?…\s*more/i)[0].trim(),w=w.split(/\n?\.\.\.\s*more/i)[0].trim(),w=w.split(/\bTop skills\b/i)[0].trim(),w=w.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=w||null}}let et=null,tt=b.find(p=>p.textContent&&p.textContent.trim()==="Activity");if(tt){let p=tt.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let w=(p.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);w&&(et=parseInt(w[1].replace(/,/g,""),10))}}let Jt=[...new Set(b.map(p=>(p.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(p=>p&&p.length>1&&p.length<60&&p!==te).filter(p=>x.has(p)))],re=document.body.textContent||"",Wt=/#OpenToWork\b/i.test(re)||/\bOpen to work\b/.test(re),Yt=/#Hiring\b/i.test(re)||/\bI'?m hiring\b/i.test(re)||/\bWe are hiring\b/i.test(re);return{name:te,title:me,location:ke,currentCompany:Ve,currentSchool:He,connectionDegree:Je,hasVerifiedBadge:Ut,photoUrl:Vt,connectionsLevel:Ye,mutualConnectionsCount:he,followers:et,openToWork:Wt,hiring:Yt,about:Qe,topSkills:Ze,availableSections:Jt}});console.log(`Viewed: ${y.name} - ${y.title}`);let u=null,f=null,C=null,v=null,_=null,h=null;if(o||r||s||i||c||a){let x=await Promise.resolve().then(()=>(gt(),ht));o&&(u=await x.extractExperienceFromDetails(e,t),console.log(` + Experience: ${u.length} entries`)),r&&(f=await x.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${f.length} entries`)),s&&(C=await x.extractEducationFromDetails(e,t),console.log(` + Education: ${C.length} entries`)),i&&(v=await x.extractSkillsFromDetails(e,t),console.log(` + Skills: ${v.length} entries`)),c&&(_=await x.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${_.length} entries`)),a&&(h=await x.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${h.length} entries`))}return{...y,profileUrl:t,...u!==null&&{experience:u},...f!==null&&{featured:f},...C!==null&&{education:C},...v!==null&&{skillsFull:v},..._!==null&&{recommendations:_},...h!==null&&{certifications:h}}}catch(m){console.error(`Error viewing profile ${t}:`,m.message);try{await e.goto("about:blank",{timeout:1e4}),await $(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(m.message||""))throw m;return null}}import"dotenv/config";import*as O from"fs";import*as j from"path";import{fileURLToPath as Dn}from"url";var Rn=Dn(import.meta.url),jn=j.dirname(j.dirname(Rn)),K=process.env.DATA_DIR?j.resolve(process.env.DATA_DIR,"market-research"):j.join(jn,"market-research"),On=j.join(K,"scouted-jobs.json"),Nn=j.join(K,"discovered-people.json"),wt=j.join(K,"visit-log.json"),Sr=j.join(K,"companies.json"),vr=j.join(K,"job-decisions.json");function Fn(){O.existsSync(K)||O.mkdirSync(K,{recursive:!0})}function Ln(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 i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function _e(e){try{if(O.existsSync(e))return JSON.parse(O.readFileSync(e,"utf-8"))}catch{}return null}function bt(){ue=null,Pn=null,de=null,qn=null,G=null}var ue=null;function Mn(){return ue||(ue=_e(On)||{},ue)}var Pn=null;var de=null;function ye(){return de||(de=_e(Nn)||{},de)}var qn=null;var G=null;function oe(){return G||(G=_e(wt)||{visits:[]},Array.isArray(G.visits)||(G.visits=[]),G)}function St(e,t={}){if(!e)return;Fn();let n=oe();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{Ln(wt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function vt(e){let t=oe();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}function kt(){let e=Mn(),t=ye(),n=Object.values(e),o=Object.values(t),r={};for(let u of n)u.company&&(r[u.company]=(r[u.company]||0)+1);let s=Object.entries(r).sort((u,f)=>f[1]-u[1]).slice(0,5).map(([u,f])=>`${u} (${f})`),i={};for(let u of n)for(let f of u.techStack||[])i[f]=(i[f]||0)+1;let c=Object.entries(i).sort((u,f)=>f[1]-u[1]).slice(0,8).map(([u,f])=>`${u} (${f})`),a=oe(),m=new Date().toISOString().slice(0,10),l=a.visits.filter(u=>u.date.startsWith(m)).length,y=new Set(a.visits.map(u=>u.profileUrl)).size;return{totalJobs:n.length,totalRecruiters:o.length,topCompanies:s,topTech:c,totalVisited:y,todayVisited:l,lastScoutDate:n.length>0?n.sort((u,f)=>(f.scoutedAt||"").localeCompare(u.scoutedAt||""))[0]?.scoutedAt:null}}se();async function Ct(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:c=!1}=n,a={visited:0,skipped:0,errors:0},m=Date.now()-s*24*60*60*1e3;for(let l of t){if(a.visited>=o)break;if(!l.profileUrl)continue;let y=vt(l.profileUrl);if(y&&new Date(y).getTime()>m){a.skipped++;continue}try{let u=await yt(e,l.profileUrl,{extractExperience:c}),f=l.source||"visit";if(u){let v={...u,source:f};c&&Array.isArray(u.experience)&&u.experience.length>0&&(v._lastEnrichedAt=new Date().toISOString()),Ee(l.profileUrl,v)}St(l.profileUrl,{name:u?.name||l.name||null,source:f}),a.visited++,i?console.log(` [${a.visited}] ${u?.name||l.profileUrl} \u2014 ${u?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let C=Math.random()*4e3;await $(r+C)}catch(u){a.errors++,i&&console.error(` Error visiting ${l.name||l.profileUrl}: ${u.message?.slice(0,60)}`);let f=(u.message||"").toLowerCase();if(f.includes("detached")||f.includes("session closed")||f.includes("target closed")||f.includes("session expired")||f.includes("bounced to")||f.includes("authwall")||f.includes("checkpoint")||f.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}function xt(e={}){let{limit:t=150,revisitDays:n=14}=e,o=oe(),r=new Set(o.visits?.map(h=>h.profileUrl)||[]),s=new Map;for(let h of o.visits||[]){let g=s.get(h.profileUrl);(!g||h.date>g)&&s.set(h.profileUrl,h.date)}let i=Date.now()-7*24*60*60*1e3,c=Date.now()-n*24*60*60*1e3;function a(h){let g=s.get(h);return g&&new Date(g).getTime()>i}let m=ye(),l=Object.entries(m).filter(([h])=>!r.has(h)).map(([h,g])=>({profileUrl:h,name:g.name,source:"new-discovered",priority:1,jobCount:g.jobIds?.length||0})),y=ie(),u=Object.entries(y).filter(([h,g])=>g.connectionStatus==="connected"||a(h)?!1:(g.jobCount||g.jobIds?.length||0)>=2).map(([h,g])=>({profileUrl:h,name:g.name,source:"active-recruiter",priority:2,jobCount:g.jobCount||g.jobIds?.length||0})),f=Object.entries(y).filter(([h,g])=>{let x=g.connectionStatus;return!(!x||x==="connected"||x==="pending"||x==="sent_without_note"||x==="sent_with_note"||a(h)||(g.jobCount||g.jobIds?.length||0)>=2)}).map(([h,g])=>({profileUrl:h,name:g.name,source:"unconnected",priority:3,jobCount:g.jobCount||g.jobIds?.length||0})),C=[...s.entries()].filter(([h,g])=>new Date(g).getTime()<c).map(([h,g])=>({profileUrl:h,name:null,source:"revisit",priority:4,lastVisit:g})),v=h=>h.sort(()=>Math.random()-.5);return l.sort((h,g)=>g.jobCount-h.jobCount),u.sort((h,g)=>g.jobCount-h.jobCount),v(f),v(C),[...l,...u,...f,...C].slice(0,t)}function $t(){let e=ye();return Object.entries(e).map(([t,n])=>({profileUrl:t,name:n.name,source:"discovered"}))}function Ie(){let e=ie();return Object.entries(e).filter(([,t])=>{let n=t.connectionStatus;return n&&n!=="connected"&&n!=="pending"&&n!=="sent_without_note"&&n!=="sent_with_note"}).map(([t,n])=>({profileUrl:t,name:n.name,source:"unconnected"}))}function Te(e=14){let t=oe(),n=Date.now()-e*24*60*60*1e3,o=new Map;for(let r of t.visits){let s=o.get(r.profileUrl);(!s||r.date>s.date)&&o.set(r.profileUrl,r)}return[...o.entries()].filter(([,r])=>new Date(r.date).getTime()<n).map(([r,s])=>({profileUrl:r,name:s.name,source:"revisit"}))}import"dotenv/config";import*as N from"fs";import*as H from"path";import{fileURLToPath as Wn}from"url";import"dotenv/config";import{createGraphClient as Bn,resolveToken as Un}from"@ilivemylife/graph-sdk";import{config as Vn}from"dotenv";Vn();var At=Un()||process.env.TOKEN;At||(console.error(`
|
|
241
|
+
`),await e.close(),process.exit(1)}return{browser:e,page:n}}se();import"dotenv/config";import*as E from"fs";import*as A from"path";import{fileURLToPath as ln}from"url";var an=ln(import.meta.url),cn=A.dirname(A.dirname(an)),B=process.env.DATA_DIR?A.resolve(process.env.DATA_DIR,"collected-profiles"):A.join(cn,"collected-profiles"),xe=A.join(B,"people.json"),nr=A.join(B,"jobs.json"),or=A.join(B,"quota.json"),rr=A.join(B,"conversations.json"),sr=A.join(B,"sync-state.json"),ir=A.join(B,"application-questions.json"),$e=A.join(B,"profile-history");var ne=null,un=null,dn=null,fn=null,mn=null,pn=null;function ut(){ne=null,un=null,dn=null,fn=null,mn=null,pn=null}function dt(){E.existsSync(B)||E.mkdirSync(B,{recursive:!0})}function ft(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";E.writeFileSync(o,n);for(let r=0;r<3;r++)try{E.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function mt(e,t){if(!E.existsSync(e))return null;try{let n=JSON.parse(E.readFileSync(e,"utf-8"));try{E.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${A.resolve(e)}`);let o=e+".backup";if(E.existsSync(o))try{let r=JSON.parse(E.readFileSync(o,"utf-8"));console.error(` Restored from ${o}`);try{E.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{E.copyFileSync(e,e+".corrupted")}catch{}return null}}function hn(){return new Date().toISOString().split("T")[0]}var gn=["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"],yn=["name","title","location","currentCompany","currentSchool","connectionDegree","hasVerifiedBadge","openToWork","hiring","about","topSkills"];function Ee(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function wn(){E.existsSync($e)||E.mkdirSync($e,{recursive:!0})}function pt(e){let t=Ee(e);return t?A.join($e,`${t}.json`):null}function bn(e){let t=pt(e);return t?mt(t,`profile-history/${Ee(e)}.json`)||[]:[]}function Sn(e,t){let n=pt(e);if(!n)return;wn();let o=bn(e);o.unshift(t);try{ft(n,o)}catch(r){console.error(`[!] Failed to append profile-history for ${Ee(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 vn(e,t){if(!e)return[];let n=[];for(let o of yn){let r=e[o],s=t[o];at(r)||at(s)||ct(r)!==ct(s)&&n.push(o)}return n}function kn(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 ie(){return ne||(dt(),ne=mt(xe,"people.json")||{},ne)}function Cn(e){dt(),ne=e;try{ft(xe,e)}catch(t){console.error(`[!] Failed to save people.json: ${t.message}`),console.error(` Path: ${A.resolve(xe)}`)}}function Ae(e,t={}){if(!e)return null;let n=ie(),o=hn(),r=new Date().toISOString(),s=n[e];if(s){let i=vn(s,t);i.length>0&&(Sn(e,{capturedAt:r,previousLastUpdated:s.lastUpdated||null,changedFields:i,snapshot:kn(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 c of gn)if(t[c]!=null){if(Array.isArray(t[c])&&t[c].length===0&&Array.isArray(s[c])&&s[c].length>0)continue;s[c]=t[c]}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 Cn(n),n[e]}async function Tn(e,t){let n=e.url();if(n.includes("/in/"))return!1;if(n.includes("/login")||n.includes("/authwall")||n.includes("/checkpoint"))throw new Error("Session expired \u2014 redirected to login. Run: npm run login");console.log(` Off-track: ${n.slice(0,80)}`),console.log(" Navigating back to profile..."),await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3);let o=e.url();return o.includes("/in/")||console.log(` Recovery failed \u2014 still on: ${o.slice(0,80)}`),!0}async function yt(e,t,n={}){let{extractExperience:o=!1,extractFeatured:r=!1,extractEducation:s=!1,extractSkills:i=!1,extractRecommendations:c=!1,extractCertifications:a=!1}=n;try{await e.goto(t,{waitUntil:"domcontentloaded",timeout:6e4}),await $(3e3),await ot(e)&&(console.log(" Dismissed Premium overlay"),await $(1500),await Tn(e,t));let l=0;for(let x=0;x<2;x++){let ee=await e.evaluate(()=>document.body.scrollHeight);for(let W=1;W<=6;W++)await e.evaluate(T=>window.scrollTo(0,T),ee*W/6),await $(900);let q=await e.evaluate(()=>document.body.scrollHeight);if(q===l)break;l=q}await $(800);let y=await e.evaluate(()=>{let x=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"]),ee=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"]),q=p=>{let w=(p||"").trim().replace(/^[·•]\s*/,"");return/^(1st|2nd|3rd|she\/her|he\/him|they\/them|their\/them)$/i.test(w)},W={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:[]},T=document.querySelector("main");if(!T)return W;let ve=[...Array.from(T.querySelectorAll("h1")),...Array.from(T.querySelectorAll("h2"))],b=Array.from(T.querySelectorAll("h2")),I=ve.find(p=>{let w=p.textContent&&p.textContent.trim(),S=(w||"").replace(/\s*\(\d+\)$/,"").trim();return w&&w.length>1&&w.length<100&&!x.has(S)&&!ee.has(S)}),te=I?I.textContent.trim():null,D=I?I.parentElement:null;for(;D&&D!==T&&!Array.from(D.children).filter(w=>w.tagName==="P").some(w=>{let S=w.textContent&&w.textContent.trim();return S&&S.length>5&&!q(S)});)D=D.parentElement;let me=null,Ve=null,He=null,ke=null;if(D&&D!==T){let p=Array.from(D.children).filter(S=>S.tagName==="P").filter(S=>{let V=S.textContent&&S.textContent.trim();return V&&V.length>5&&!q(V)});if(p[0]&&(me=p[0].textContent.trim()),p[1]){let S=p[1].textContent.trim().split(/\s*[·•]\s*/);Ve=S[0]||null,S.length>1&&(He=S.slice(1).join(" \xB7 "))}let w=Array.from(D.children).filter(S=>S.tagName==="DIV");for(let S=w.length-1;S>=0;S--){let V=w[S].textContent&&w[S].textContent.trim();if(V&&!(te&&V.startsWith(te))&&(ke=V.split(/[·•]/)[0].trim(),ke))break}}let Je=null;if(D){let p=D.querySelectorAll("p, span, div");for(let w of p){let S=(w.textContent||"").trim().replace(/^[·•]\s*/,"");if(S==="1st"||S==="2nd"||S==="3rd"){Je=S;break}}}let Ut=!!T.querySelector('svg[data-test-icon="verified"], [aria-label*="Verified" i]'),We=document.querySelector('main img[width="200"], button img[alt*="photo" i]'),Vt=We&&We.src||null,pe=T.textContent||"",Ye=null,Ge=pe.match(/(\d+\+?)\s+connections\b/i);Ge&&(Ye=Ge[1]+" connections");let he=null,Ke=pe.match(/(\d+)\s+mutual connection/i),ze=pe.match(/and\s+(\d+)\s+other mutual/i),Ht=pe.match(/([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+and\s+([A-Z][\w'-]+(?:\s+[A-Z][\w'-]+)?)\s+are\s+mutual/);Ke?he=parseInt(Ke[1],10):ze?he=2+parseInt(ze[1],10):Ht&&(he=2);let Qe=null,Ze=null,Xe=b.find(p=>p.textContent&&p.textContent.trim()==="About");if(Xe){let p=Xe.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let w=(p.textContent||"").trim();w=w.replace(/^About\s*/,"").trim();let S=w.match(/Top skills\s*(.+?)$/i);if(S){let Ce=S[1].split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim().split(/\s*[·•]\s*/).map(Gt=>Gt.trim()).filter(Boolean);Ce.length>0&&Ce.length<10&&(Ze=Ce)}w=w.split(/\n?…\s*more/i)[0].trim(),w=w.split(/\n?\.\.\.\s*more/i)[0].trim(),w=w.split(/\bTop skills\b/i)[0].trim(),w=w.split(/\b(?:see (?:more|less)|show (?:more|less))\b/i)[0].trim(),Qe=w||null}}let et=null,tt=b.find(p=>p.textContent&&p.textContent.trim()==="Activity");if(tt){let p=tt.parentElement;for(;p&&p.tagName!=="SECTION";)p=p.parentElement;if(p){let w=(p.textContent||"").slice(0,200).match(/([\d,]+)\s+followers/i);w&&(et=parseInt(w[1].replace(/,/g,""),10))}}let Jt=[...new Set(b.map(p=>(p.textContent||"").trim().replace(/\s*\(\d+\)$/,"").trim()).filter(p=>p&&p.length>1&&p.length<60&&p!==te).filter(p=>x.has(p)))],re=document.body.textContent||"",Wt=/#OpenToWork\b/i.test(re)||/\bOpen to work\b/.test(re),Yt=/#Hiring\b/i.test(re)||/\bI'?m hiring\b/i.test(re)||/\bWe are hiring\b/i.test(re);return{name:te,title:me,location:ke,currentCompany:Ve,currentSchool:He,connectionDegree:Je,hasVerifiedBadge:Ut,photoUrl:Vt,connectionsLevel:Ye,mutualConnectionsCount:he,followers:et,openToWork:Wt,hiring:Yt,about:Qe,topSkills:Ze,availableSections:Jt}});console.log(`Viewed: ${y.name} - ${y.title}`);let u=null,f=null,C=null,v=null,_=null,h=null;if(o||r||s||i||c||a){let x=await Promise.resolve().then(()=>(gt(),ht));o&&(u=await x.extractExperienceFromDetails(e,t),console.log(` + Experience: ${u.length} entries`)),r&&(f=await x.extractFeaturedFromDetails(e,t),console.log(` + Featured: ${f.length} entries`)),s&&(C=await x.extractEducationFromDetails(e,t),console.log(` + Education: ${C.length} entries`)),i&&(v=await x.extractSkillsFromDetails(e,t),console.log(` + Skills: ${v.length} entries`)),c&&(_=await x.extractRecommendationsFromDetails(e,t),console.log(` + Recommendations: ${_.length} entries`)),a&&(h=await x.extractCertificationsFromDetails(e,t),console.log(` + Certifications: ${h.length} entries`))}return{...y,profileUrl:t,...u!==null&&{experience:u},...f!==null&&{featured:f},...C!==null&&{education:C},...v!==null&&{skillsFull:v},..._!==null&&{recommendations:_},...h!==null&&{certifications:h}}}catch(m){console.error(`Error viewing profile ${t}:`,m.message);try{await e.goto("about:blank",{timeout:1e4}),await $(1e3)}catch{}if(/session expired|bounced to|authwall|checkpoint|redirected to login/i.test(m.message||""))throw m;return null}}import"dotenv/config";import*as O from"fs";import*as j from"path";import{fileURLToPath as Dn}from"url";var Rn=Dn(import.meta.url),jn=j.dirname(j.dirname(Rn)),K=process.env.DATA_DIR?j.resolve(process.env.DATA_DIR,"market-research"):j.join(jn,"market-research"),On=j.join(K,"scouted-jobs.json"),Nn=j.join(K,"discovered-people.json"),wt=j.join(K,"visit-log.json"),Sr=j.join(K,"companies.json"),vr=j.join(K,"job-decisions.json");function Ln(){O.existsSync(K)||O.mkdirSync(K,{recursive:!0})}function Fn(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 i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function _e(e){try{if(O.existsSync(e))return JSON.parse(O.readFileSync(e,"utf-8"))}catch{}return null}function bt(){ue=null,Pn=null,de=null,qn=null,G=null}var ue=null;function Mn(){return ue||(ue=_e(On)||{},ue)}var Pn=null;var de=null;function ye(){return de||(de=_e(Nn)||{},de)}var qn=null;var G=null;function oe(){return G||(G=_e(wt)||{visits:[]},Array.isArray(G.visits)||(G.visits=[]),G)}function St(e,t={}){if(!e)return;Ln();let n=oe();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{Fn(wt,n)}catch(r){console.error(`[!] Failed to save visit-log.json: ${r.message}`)}}function vt(e){let t=oe();for(let n=t.visits.length-1;n>=0;n--)if(t.visits[n].profileUrl===e)return t.visits[n].date;return null}function kt(){let e=Mn(),t=ye(),n=Object.values(e),o=Object.values(t),r={};for(let u of n)u.company&&(r[u.company]=(r[u.company]||0)+1);let s=Object.entries(r).sort((u,f)=>f[1]-u[1]).slice(0,5).map(([u,f])=>`${u} (${f})`),i={};for(let u of n)for(let f of u.techStack||[])i[f]=(i[f]||0)+1;let c=Object.entries(i).sort((u,f)=>f[1]-u[1]).slice(0,8).map(([u,f])=>`${u} (${f})`),a=oe(),m=new Date().toISOString().slice(0,10),l=a.visits.filter(u=>u.date.startsWith(m)).length,y=new Set(a.visits.map(u=>u.profileUrl)).size;return{totalJobs:n.length,totalRecruiters:o.length,topCompanies:s,topTech:c,totalVisited:y,todayVisited:l,lastScoutDate:n.length>0?n.sort((u,f)=>(f.scoutedAt||"").localeCompare(u.scoutedAt||""))[0]?.scoutedAt:null}}se();async function Ct(e,t,n={}){let{maxVisits:o=50,delayBetween:r=4e3,skipRecentDays:s=7,verbose:i=!1,extractExperience:c=!1}=n,a={visited:0,skipped:0,errors:0},m=Date.now()-s*24*60*60*1e3;for(let l of t){if(a.visited>=o)break;if(!l.profileUrl)continue;let y=vt(l.profileUrl);if(y&&new Date(y).getTime()>m){a.skipped++;continue}try{let u=await yt(e,l.profileUrl,{extractExperience:c}),f=l.source||"visit";if(u){let v={...u,source:f};c&&Array.isArray(u.experience)&&u.experience.length>0&&(v._lastEnrichedAt=new Date().toISOString()),Ae(l.profileUrl,v)}St(l.profileUrl,{name:u?.name||l.name||null,source:f}),a.visited++,i?console.log(` [${a.visited}] ${u?.name||l.profileUrl} \u2014 ${u?.title?.slice(0,40)||"?"}`):a.visited%10===0&&console.log(` Visited: ${a.visited}`);let C=Math.random()*4e3;await $(r+C)}catch(u){a.errors++,i&&console.error(` Error visiting ${l.name||l.profileUrl}: ${u.message?.slice(0,60)}`);let f=(u.message||"").toLowerCase();if(f.includes("detached")||f.includes("session closed")||f.includes("target closed")||f.includes("session expired")||f.includes("bounced to")||f.includes("authwall")||f.includes("checkpoint")||f.includes("redirected to login")){console.log(" Fatal browser/session error \u2014 stopping visits");break}}}return a}function xt(e={}){let{limit:t=150,revisitDays:n=14}=e,o=oe(),r=new Set(o.visits?.map(h=>h.profileUrl)||[]),s=new Map;for(let h of o.visits||[]){let g=s.get(h.profileUrl);(!g||h.date>g)&&s.set(h.profileUrl,h.date)}let i=Date.now()-7*24*60*60*1e3,c=Date.now()-n*24*60*60*1e3;function a(h){let g=s.get(h);return g&&new Date(g).getTime()>i}let m=ye(),l=Object.entries(m).filter(([h])=>!r.has(h)).map(([h,g])=>({profileUrl:h,name:g.name,source:"new-discovered",priority:1,jobCount:g.jobIds?.length||0})),y=ie(),u=Object.entries(y).filter(([h,g])=>g.connectionStatus==="connected"||a(h)?!1:(g.jobCount||g.jobIds?.length||0)>=2).map(([h,g])=>({profileUrl:h,name:g.name,source:"active-recruiter",priority:2,jobCount:g.jobCount||g.jobIds?.length||0})),f=Object.entries(y).filter(([h,g])=>{let x=g.connectionStatus;return!(!x||x==="connected"||x==="pending"||x==="sent_without_note"||x==="sent_with_note"||a(h)||(g.jobCount||g.jobIds?.length||0)>=2)}).map(([h,g])=>({profileUrl:h,name:g.name,source:"unconnected",priority:3,jobCount:g.jobCount||g.jobIds?.length||0})),C=[...s.entries()].filter(([h,g])=>new Date(g).getTime()<c).map(([h,g])=>({profileUrl:h,name:null,source:"revisit",priority:4,lastVisit:g})),v=h=>h.sort(()=>Math.random()-.5);return l.sort((h,g)=>g.jobCount-h.jobCount),u.sort((h,g)=>g.jobCount-h.jobCount),v(f),v(C),[...l,...u,...f,...C].slice(0,t)}function $t(){let e=ye();return Object.entries(e).map(([t,n])=>({profileUrl:t,name:n.name,source:"discovered"}))}function Ie(){let e=ie();return Object.entries(e).filter(([,t])=>{let n=t.connectionStatus;return n&&n!=="connected"&&n!=="pending"&&n!=="sent_without_note"&&n!=="sent_with_note"}).map(([t,n])=>({profileUrl:t,name:n.name,source:"unconnected"}))}function Te(e=14){let t=oe(),n=Date.now()-e*24*60*60*1e3,o=new Map;for(let r of t.visits){let s=o.get(r.profileUrl);(!s||r.date>s.date)&&o.set(r.profileUrl,r)}return[...o.entries()].filter(([,r])=>new Date(r.date).getTime()<n).map(([r,s])=>({profileUrl:r,name:s.name,source:"revisit"}))}import"dotenv/config";import*as N from"fs";import*as H from"path";import{fileURLToPath as Wn}from"url";import"dotenv/config";import{createGraphClient as Bn,resolveToken as Un}from"@ilivemylife/graph-sdk";import{config as Vn}from"dotenv";Vn();var Et=Un()||process.env.TOKEN;Et||(console.error(`
|
|
217
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.
|
|
218
243
|
`),console.error(" Easiest way:"),console.error(" 1. npm install -g @ilivemylife/graph-sdk"),console.error(` 2. ilml login your@email.com yourpassword
|
|
219
244
|
`),console.error(` Or add ILML_TOKEN=... to .env
|
|
220
|
-
`),process.exit(1));var
|
|
245
|
+
`),process.exit(1));var At=Bn({token:Et});function Hn(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 Jn({scriptName:e,mode:t,status:n,error:o,duration:r}){let s=n==="error"?"\u2717":n==="quota-reached"?"\u26A0":"\u2713",i=new Date().toISOString().slice(0,16).replace("T"," "),c=r?` ${Hn(r)}`:"",a=n==="error"?`error${o?`: ${String(o).slice(0,80)}`:""}`:n==="quota-reached"?"daily quota reached":"done",m=t&&t!=="default"?` (${t})`:"";return`${s} ${e}${m} \u2014 ${a} \u2014 ${i}${c}`}async function _t({scriptName:e,mode:t,status:n,summaryLines:o,error:r,duration:s}){let i=process.env.NODE_RUN_REPORTS;if(!i||!Array.isArray(o)||o.length===0)return;let a=`**${Jn({scriptName:e,mode:t,status:n,error:r,duration:s})}**
|
|
221
246
|
|
|
222
247
|
${o.join(`
|
|
223
|
-
`)}`;try{await
|
|
248
|
+
`)}`;try{await At.addMessage(i,a)}catch(m){console.error(`[runReport] Failed to post end-of-session message: ${m.message}`)}}var Yn=Wn(import.meta.url),Gn=H.dirname(H.dirname(Yn)),De=process.env.DATA_DIR?H.resolve(process.env.DATA_DIR,"collected-profiles"):H.join(Gn,"collected-profiles"),Re=H.join(De,"run-log.json");function Kn(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";N.writeFileSync(o,n);for(let r=0;r<3;r++)try{N.renameSync(o,e);return}catch(s){if(r<2&&(s.code==="EPERM"||s.code==="EBUSY")){let i=Date.now();for(;Date.now()-i<200;);continue}throw s}}function It(){try{if(!N.existsSync(Re))return{runs:[]};let e=JSON.parse(N.readFileSync(Re,"utf-8"));return!e.runs||!Array.isArray(e.runs)?{runs:[]}:e}catch{return{runs:[]}}}function Tt(e){N.existsSync(De)||N.mkdirSync(De,{recursive:!0});try{Kn(Re,e)}catch(t){console.error(`[!] Failed to save run-log.json: ${t.message}`)}}function Dt(e,t="default"){let n=It();for(let i of n.runs)i.status==="running"&&(i.status="interrupted",i.result="interrupted",i.timestamp&&(i.duration=Date.now()-new Date(i.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(i=>new Date(i.timestamp).getTime()>s),Tt(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 i=It(),c=i.runs[e.runIndex];if(c&&c.status==="running"&&c.script===e.script)c.status=t,c.result=t,c.duration=Date.now()-e.startTime,c.stats=n,c.error=o,r=c.duration;else{let a=i.runs.find(m=>m.script===e.script&&m.status==="running"&&m.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)}Tt(i)}catch(i){console.error(`[runLog] Failed to end run: ${i.message}`)}let s=n&&Array.isArray(n.summaryLines)?n.summaryLines:null;if(s&&s.length>0&&process.env.NODE_RUN_REPORTS){let i=t==="error"?"error":n&&n.dailyLimitHit?"quota-reached":"done";_t({scriptName:e.script,mode:e.mode,status:i,summaryLines:s,error:o,duration:r??Date.now()-e.startTime}).catch(c=>console.error(`[runLog] postRunReport failed: ${c.message}`))}}import"dotenv/config";import*as d from"fs";import*as qe from"os";import*as k from"path";import{fileURLToPath as po}from"url";var Le={};ge(Le,{NAME:()=>Qn,VERSION:()=>zn,up:()=>eo});import*as L from"fs";import*as we from"path";var zn=1,Qn="normalize-jobs-and-questions",Zn=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Xn=50;function Oe(e){return L.existsSync(e)?JSON.parse(L.readFileSync(e,"utf-8")):null}function Ne(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 eo(e,t){let n=we.join(e,"jobs.json"),o=we.join(t,"scouted-jobs.json"),r=we.join(e,"application-questions.json"),s=Oe(n)||{},i=Oe(o)||{},c=0,a=[];for(let l of Object.keys(s)){if(!i[l])continue;let y=i[l],u=s[l];for(let f of Zn)y[f]!=null&&u[f]==null&&(u[f]=y[f]);a.push(l),c++}c>0?(Ne(n,s),console.log(` Phase 1: Merged ${c} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let m=Oe(r);if(m&&Array.isArray(m.applications)){let l={},y=0;for(let u of m.applications){let f=u.jobId||"unknown";l[f]||(l[f]={applications:[]});let C=(u.questions||[]).map(v=>{let _={type:v.type||"input",question:v.question||"",answer:v.answer||""};return v.options&&(v.options.length<=Xn?_.options=v.options:(_.optionsOmitted=!0,y++)),v.page&&(_.page=v.page),v.wasPreFilled&&(_.wasPreFilled=!0),v.wasRetry&&(_.wasRetry=!0),_});l[f].applications.push({applicationId:u.applicationId,date:u.date,result:u.result||"submitted",formPages:u.formPages||null,duration:u.duration||null,retries:u.retries||0,failedField:u.failedField||null,questionCount:u.questionCount||C.length,questions:C})}Ne(r,l),console.log(` Phase 2: Rekeyed ${m.applications.length} applications by jobId (${Object.keys(l).length} unique jobs)`),y>0&&console.log(` Phase 2: Stripped bloated options from ${y} questions`)}else m&&!m.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 l of a)delete i[l];Ne(o,i),console.log(` Phase 3: Removed ${a.length} merged entries from scouted-jobs.json (${Object.keys(i).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var Fe={};ge(Fe,{NAME:()=>no,VERSION:()=>to,up:()=>so});import*as F from"fs";import*as Rt from"path";var to=2,no="reset-unread-flags";function oo(e){return F.existsSync(e)?JSON.parse(F.readFileSync(e,"utf-8")):null}function ro(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}}async function so(e){let t=Rt.join(e,"conversations.json"),n=oo(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}ro(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={};ge(Me,{NAME:()=>lo,VERSION:()=>io,up:()=>mo});import*as M from"fs";import*as jt from"path";var io=3,lo="recompute-last-message-by",ao=new Set(["draft","confirmed","rejected","needs_review"]);function co(e){return M.existsSync(e)?JSON.parse(M.readFileSync(e,"utf-8")):null}function uo(e,t){let n=JSON.stringify(t,null,2),o=e+".tmp";try{M.writeFileSync(o,n)}catch(r){try{M.unlinkSync(o)}catch{}throw r}try{M.renameSync(o,e)}catch(r){try{M.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 fo(e,t){if(!e||e.length===0)return"them";let n=e.filter(s=>!ao.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,i)=>i.t-s.t).map(s=>s.m),r=o.length>0?o:[...n].reverse();for(let s of r){let i=s.sender;if(i===t)return"me";if(i!=="Unknown"&&i!=="")return"them"}return"them"}async function mo(e){let t=jt.join(e,"conversations.json"),n=co(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,i=0;for(let c of Object.keys(n)){let a=n[c];if(!a||typeof a!="object")continue;Object.prototype.hasOwnProperty.call(a,"_cardSynced")&&(delete a._cardSynced,s++);let m=Array.isArray(a.messages)?a.messages:[],l=fo(m,o),y=l==="me"?"awaiting_reply":"unanswered_by_us";a.lastMessageBy!==l&&i++,a.lastMessageBy=l,a.conversationStatus=y,r++}if(r===0){console.log(" No conversations to recompute.");return}uo(t,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${i} 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 ho=po(import.meta.url),go=k.dirname(ho),yo=k.dirname(k.dirname(go));function wo(e){return e&&(e==="~"?qe.homedir():e.startsWith("~/")||e.startsWith("~\\")?k.join(qe.homedir(),e.slice(2)):e)}var P=process.env.DATA_DIR?k.resolve(wo(process.env.DATA_DIR)):yo,Q=k.join(P,"collected-profiles"),Z=k.join(P,"market-research"),R=k.join(P,".schema-version"),Ot=[k.join(Q,".schema-version"),k.join(Z,".schema-version")],J=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!==J)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${J}. 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 Mt(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
224
249
|
[FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
|
|
225
250
|
`),process.exit(1));try{d.mkdirSync(P,{recursive:!0})}catch(t){t.code!=="EEXIST"&&(console.error(`
|
|
226
251
|
[FATAL] Cannot create DATA_DIR (${P}): ${t.message}`),console.error(` Fix the path or permissions and try again.
|
|
@@ -238,11 +263,11 @@ ${o.join(`
|
|
|
238
263
|
Repair the file(s) (likely just an integer 'version' field \u2014 see another working DATA_DIR`),console.error(` or default to {"version":1,"migrations":[]} if you're sure you're on schema v1) and try again.
|
|
239
264
|
`),process.exit(1)}if(e.length===0)return;let n=e.map(s=>s.schema.version);if(new Set(n).size>1){console.error(`
|
|
240
265
|
[FATAL] Legacy .schema-version files disagree:`);for(let s of e)console.error(` ${s.file}: v${s.schema.version}`);console.error(" This means a previous migration crashed between writing the two files."),console.error(` Reconcile manually (delete the wrong one, keep the right one), then re-run.
|
|
241
|
-
`),process.exit(1)}let o=e[0].schema,r=R+".tmp";try{d.writeFileSync(r,JSON.stringify(o,null,2)),d.renameSync(r,R)}catch(s){try{d.unlinkSync(r)}catch{}throw s}for(let s of Ot)if(d.existsSync(s))try{d.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${R}`)}function ko(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Number(e.version);return!Number.isFinite(t)||t<0||!Number.isInteger(t)?null:(e.version=t,Array.isArray(e.migrations)||(e.migrations=[]),e)}function be(e){let t=d.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function
|
|
266
|
+
`),process.exit(1)}let o=e[0].schema,r=R+".tmp";try{d.writeFileSync(r,JSON.stringify(o,null,2)),d.renameSync(r,R)}catch(s){try{d.unlinkSync(r)}catch{}throw s}for(let s of Ot)if(d.existsSync(s))try{d.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${R}`)}function ko(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Number(e.version);return!Number.isFinite(t)||t<0||!Number.isInteger(t)?null:(e.version=t,Array.isArray(e.migrations)||(e.migrations=[]),e)}function be(e){let t=d.readFileSync(e,"utf-8");return t.charCodeAt(0)===65279&&(t=t.slice(1)),JSON.parse(t)}function Lt(){if(vo(),!d.existsSync(R))return{version:0,migrations:[]};let e;try{e=be(R)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
242
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.
|
|
243
268
|
`),process.exit(1)}let t=ko(e);return t===null&&(console.error(`
|
|
244
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.
|
|
245
|
-
`),process.exit(1)),t}function Pt(e){try{d.chmodSync(e,384)}catch{}}function Co(e){if(Mt(),d.existsSync(R))try{if(d.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{d.writeFileSync(t,JSON.stringify(e,null,2)),Pt(t),d.renameSync(t,R)}catch(n){try{d.unlinkSync(t)}catch{}throw n}}function
|
|
270
|
+
`),process.exit(1)),t}function Pt(e){try{d.chmodSync(e,384)}catch{}}function Co(e){if(Mt(),d.existsSync(R))try{if(d.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{d.writeFileSync(t,JSON.stringify(e,null,2)),Pt(t),d.renameSync(t,R)}catch(n){try{d.unlinkSync(t)}catch{}throw n}}function Ft(e,t){if(!d.existsSync(e))return;let n=`.pre-v${String(t).padStart(3,"0")}.backup`,o=d.readdirSync(e).filter(c=>{let a=c.toLowerCase();if(a.includes(".backup")||a===".schema-version"||a.endsWith(".tmp"))return!1;try{return d.statSync(k.join(e,c)).isFile()}catch{return!1}}),r=0,s=0,i=[];for(let c of o){let a=k.join(e,c),m=k.join(e,c+n);if(d.existsSync(m)){s++;continue}try{Bt(a,m),r++}catch(l){i.push({file:c,err:l.message})}}if(i.length>0){let c=new Error(`Failed to back up ${i.length} file(s) in ${k.basename(e)}/: `+i.map(a=>`${a.file} (${a.err})`).join(", "));throw c.code="BACKUP_INCOMPLETE",c}if(r>0||s>0){let c=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${k.basename(e)}/ (${n})${c}`)}}var Pe=!1;async function qt(){if(Pe)return;Mt(),_o();let t=Lt().version;if(t===J){Pe=!0;return}So(),bo(),process.on("exit",Be),t>J&&(console.error(`
|
|
246
271
|
[FATAL] Your data schema is at v${t}, but this plugin build only understands up to v${J}.`),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.
|
|
247
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${J}.
|
|
248
273
|
`),process.exit(1)),console.log(`
|
|
@@ -250,17 +275,17 @@ ${o.join(`
|
|
|
250
275
|
[FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let r of n.broken)console.error(` ${r.dir}/${r.file}: ${r.err}`);console.error(`
|
|
251
276
|
Migration ABORTED. No backups taken, no files modified.`),console.error(" Repair the file(s) above (restore from your own backup, or fix manually)"),console.error(` and try again. To inspect: 'ilml linkedin migrate-status'.
|
|
252
277
|
`),process.exit(1)}let o=U.filter(r=>r.version>t);for(let r of o){console.log(`
|
|
253
|
-
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{
|
|
278
|
+
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,i=`.pre-${s}.backup`;try{Ft(Q,r.version),Ft(Z,r.version)}catch(a){console.error(`
|
|
254
279
|
[FATAL] Pre-migration backup failed for ${s}: ${a.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
|
|
255
280
|
`),process.exit(1)}let c=r.module;try{await c.up(Q,Z)}catch(a){console.error(`
|
|
256
281
|
[FATAL] Migration ${s} failed: ${a.message}`),console.error(` Attempting auto-rollback from ${i} files...`);try{let m=To(i);m.ok?(console.error(` \u2713 Auto-rollback restored ${m.restored} files. Schema stays at v${t}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
|
|
257
282
|
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${m.error}`),console.error(` Manual recovery: copy *${i} files back over the originals.
|
|
258
283
|
`))}catch(m){console.error(` [!] Auto-rollback CRASHED while restoring: ${m.message}`),console.error(` Manual recovery: copy *${i} files back over the originals.
|
|
259
|
-
`)}process.exit(1)}try{let a=new Date().toISOString(),m={version:r.version,name:c.NAME||s,appliedAt:a},l=
|
|
284
|
+
`)}process.exit(1)}try{let a=new Date().toISOString(),m={version:r.version,name:c.NAME||s,appliedAt:a},l=Lt();l.version=r.version,l.migratedAt=a,l.migrations=l.migrations||[],l.migrations.push(m),Co(l)}catch(a){console.error(`
|
|
260
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.
|
|
261
286
|
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{ut()}catch{}try{bt()}catch{}Pe=!0,Be(),console.log(`
|
|
262
287
|
\u2713 Schema is now at v${J}
|
|
263
|
-
`)}var xo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function $o(e){let t=e.toLowerCase();return xo.some(n=>n.test(t))}var
|
|
288
|
+
`)}var xo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function $o(e){let t=e.toLowerCase();return xo.some(n=>n.test(t))}var Eo=6e4;function Ao(){let e=Date.now(),t=[];for(let n of[P,Q,Z]){if(!d.existsSync(n))continue;let o;try{o=d.readdirSync(n)}catch{continue}for(let r of o){if(!$o(r))continue;let s=k.join(n,r);try{let i=d.statSync(s);if(!i.isFile()||e-i.mtimeMs<Eo)continue;t.push({dir:n,file:r,fullPath:s})}catch{}}}return t}function _o({verbose:e=!1}={}){let t=Ao();if(t.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let o of t)try{d.unlinkSync(o.fullPath),n++,e&&console.log(` Removed orphan: ${k.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 Io(){let e=[];for(let t of[Q,Z]){if(!d.existsSync(t))continue;let n=d.readdirSync(t).filter(o=>{let r=o.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let o of n){let r=k.join(t,o);try{be(r)}catch(s){e.push({dir:k.basename(t),file:o,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function To(e){let t=[],n=[];for(let s of[Q,Z]){if(!d.existsSync(s))continue;let i=d.readdirSync(s).filter(c=>c.endsWith(e));for(let c of i){let a=k.join(s,c),m=c.slice(0,-e.length),l=k.join(s,m);try{m.toLowerCase().endsWith(".json")?be(a):d.accessSync(a,d.constants.R_OK),t.push({backupPath:a,originalPath:l,fileName:c,dir:s})}catch(y){n.push(`${k.basename(s)}/${c}: ${y.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let o=0,r=[];for(let{backupPath:s,originalPath:i,fileName:c,dir:a}of t)try{Bt(s,i),o++}catch(m){r.push(`${k.basename(a)}/${c}: ${m.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:o}:{ok:!0,restored:o}}function Bt(e,t){let n=t+".tmp";try{d.copyFileSync(e,n),Pt(n)}catch(o){try{d.unlinkSync(n)}catch{}throw o}try{d.renameSync(n,t)}catch(o){try{d.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 qt();var fe=process.argv.slice(2),Se=fe.find(e=>e.startsWith("--source="))?.split("=")[1]||"scouted",Ue=parseInt(fe.find(e=>e.startsWith("--max="))?.split("=")[1]||"50"),X=parseInt(fe.find(e=>e.startsWith("--revisit="))?.split("=")[1]||"0"),Do=fe.includes("--list"),Ro=fe.includes("--verbose");function jo(){let e=kt();console.log(`
|
|
264
289
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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 VISIT STATS"),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(` Unique profiles visited: ${e.totalVisited}`),console.log(` Today: ${e.todayVisited}`),console.log(` Discovered recruiters: ${e.totalRecruiters} (potential visits)`);let t=Ie();if(console.log(` Unconnected recruiters: ${t.length}`),X>0){let n=Te(X);console.log(` Revisit (>${X}d ago): ${n.length}`)}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
|
|
265
290
|
`)}async function Oo(){if(console.log(`
|
|
266
291
|
LinkedIn Profile Visitor
|
package/ilml-plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkedin",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "Reference ilml plugin: keep a local mirror of your LinkedIn data with AI-assisted workflows",
|
|
5
5
|
"commands": {
|
|
6
6
|
"help": { "run": "node dist/help.mjs", "description": "List all commands with descriptions; or `help <cmd>` for detailed info on one command (usage, flags, ban-risk, when-to-use). Reads ilml-plugin.json directly.", "usage": "ilml linkedin help [<cmd>]", "useWhen": "You forgot what a command does, or you're an AI agent picking the right tool." },
|
package/package.json
CHANGED