@ubaidbinwaris/linkedin 1.0.8 → 1.0.9
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/package.json +1 -1
- package/src/login/login.js +33 -0
package/package.json
CHANGED
package/src/login/login.js
CHANGED
|
@@ -156,6 +156,39 @@ async function loginToLinkedIn(options = {}, credentials = null) {
|
|
|
156
156
|
if (launchOptions.headless) {
|
|
157
157
|
logger.warn("Checkpoint detected in headless mode.");
|
|
158
158
|
|
|
159
|
+
// Attempt to resolve simple checkpoints (e.g. "Yes, it's me", "Skip") automatically
|
|
160
|
+
try {
|
|
161
|
+
logger.info("Attempting to resolve simple checkpoint headlessly...");
|
|
162
|
+
const simpleResolved = await page.evaluate(async () => {
|
|
163
|
+
const buttons = Array.from(document.querySelectorAll('button'));
|
|
164
|
+
const targetText = ['Yes', 'Skip', 'Not now', 'Continue', 'Sign in'];
|
|
165
|
+
// Find a button with one of these texts
|
|
166
|
+
const btn = buttons.find(b => targetText.some(t => b.innerText.includes(t)));
|
|
167
|
+
if (btn) {
|
|
168
|
+
btn.click();
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (simpleResolved) {
|
|
175
|
+
logger.info("Clicked a resolution button. Waiting to see if it clears...");
|
|
176
|
+
await randomDelay(2000, 4000);
|
|
177
|
+
if (!(await detectCheckpoint(page))) {
|
|
178
|
+
logger.info("Checkpoint resolved headlessly! Proceeding...");
|
|
179
|
+
// Re-verify session
|
|
180
|
+
try {
|
|
181
|
+
await page.waitForURL("**/feed**", { timeout: 10000 });
|
|
182
|
+
return { browser, context, page };
|
|
183
|
+
} catch (e) {
|
|
184
|
+
logger.warn("Resolved checkpoint but feed did not load. Continuing...");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
logger.warn(`Failed to auto-resolve checkpoint: ${err.message}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
159
192
|
if (options.onCheckpoint && typeof options.onCheckpoint === 'function') {
|
|
160
193
|
logger.info("Triggering onCheckpoint callback...");
|
|
161
194
|
await options.onCheckpoint();
|