@ubaidbinwaris/linkedin 1.0.10 → 1.0.11

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/login/login.js +39 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubaidbinwaris/linkedin",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -304,6 +304,45 @@ async function loginToLinkedIn(options = {}, credentials = null) {
304
304
  if (launchOptions.headless) {
305
305
  logger.warn("Checkpoint detected in headless mode (post-login).");
306
306
 
307
+ // Attempt to resolve simple checkpoints (e.g. "Yes, it's me", "Skip") automatically
308
+ try {
309
+ logger.info("Attempting to resolve simple checkpoint headlessly (post-login)...");
310
+ const simpleResolved = await page.evaluate(async () => {
311
+ // Find buttons, links, or elements with button role
312
+ const candidates = Array.from(document.querySelectorAll('button, a, [role="button"], input[type="submit"], input[type="button"]'));
313
+ const targetText = ['Yes', 'Skip', 'Not now', 'Continue', 'Sign in', 'Verify', 'Let’s do it', 'Next'];
314
+
315
+ // Find a candidate with one of these texts
316
+ const btn = candidates.find(b => {
317
+ const text = (b.innerText || b.value || '').trim();
318
+ return targetText.some(t => text.includes(t));
319
+ });
320
+
321
+ if (btn) {
322
+ btn.click();
323
+ return true;
324
+ }
325
+ return false;
326
+ });
327
+
328
+ if (simpleResolved) {
329
+ logger.info("Clicked a resolution button. Waiting to see if it clears...");
330
+ await randomDelay(2000, 4000);
331
+ if (!(await detectCheckpoint(page))) {
332
+ logger.info("Checkpoint resolved headlessly! Proceeding...");
333
+ // Re-verify session
334
+ try {
335
+ await page.waitForURL("**/feed**", { timeout: 10000 });
336
+ return { browser, context, page };
337
+ } catch (e) {
338
+ logger.warn("Resolved checkpoint but feed did not load. Continuing...");
339
+ }
340
+ }
341
+ }
342
+ } catch (err) {
343
+ logger.warn(`Failed to auto-resolve post-login checkpoint: ${err.message}`);
344
+ }
345
+
307
346
  if (options.onCheckpoint && typeof options.onCheckpoint === 'function') {
308
347
  logger.info("Triggering onCheckpoint callback...");
309
348
  await options.onCheckpoint();