Update to allow manually filling out the security code when newegg forces you to use 2fa

This commit is contained in:
Kevin MacMartin 2020-12-31 20:35:51 -05:00
parent a337d0ad01
commit 34f2e4f9ca
1 changed files with 19 additions and 10 deletions

View File

@ -44,15 +44,24 @@ async function run() {
await page.click("button.btn.btn-orange");
await page.waitForTimeout(1500);
try {
await page.waitForSelector("#labeled-input-password", { timeout: 2500 });
await page.waitForSelector("button.btn.btn-orange");
await page.type("#labeled-input-password", config.password);
await page.click("button.btn.btn-orange");
log("Successfully logged in");
} catch (err) {
log("Fail: Manual authorization code required by Newegg. This should only happen once.");
success = false;
while (true) {
try {
await page.waitForSelector("#labeled-input-password", { timeout: 2500 });
await page.waitForSelector("button.btn.btn-orange");
await page.type("#labeled-input-password", config.password);
await page.click("button.btn.btn-orange");
log("Successfully logged in");
break;
} catch (err) {
try {
await page.waitForSelector(".nav-complex-inner .fa-caret-down", { timeout: 2500 });
log("Successfully logged in");
break;
} catch (err) {
log("Waiting for authorization");
await page.waitForTimeout(5000);
}
}
}
} catch (err) {
log("Fail: Login form missing");
@ -157,7 +166,7 @@ async function run() {
}
if (!success) {
await browser.close();
// await browser.close();
}
}