← back to Eur Recrawl
reset-dg.mjs
55 lines
// reset-dg.mjs — complete the DG consumer-account password reset (Steve-initiated).
// Engine-selectable to get past Cloudflare: ENGINE=webkit|firefox|chrome (default webkit)
// pw read from /tmp/dg-newpw.txt (never inline). Token from the info@ reset email.
import { chromium, firefox, webkit } from 'playwright';
import fs from 'node:fs';
import path from 'node:path';
const pw = fs.readFileSync('/tmp/dg-newpw.txt', 'utf8').trim();
const email = 'info@designerwallcoverings.com';
const url = 'https://www.designersguild.com/en-us/password-reset/l181?token=68DA5BFD-EAFA-48D6-BC0A-EDBCD830AA5EE9A50F873C1CCCB98E74';
const ENGINE = (process.env.ENGINE || 'webkit').toLowerCase();
const engines = { webkit, firefox, chrome: chromium };
const drv = engines[ENGINE] || webkit;
const authDir = path.join(process.cwd(), '.auth', `dg-${ENGINE}`);
console.log(`engine: ${ENGINE}`);
const launchOpts = { headless: false, viewport: { width: 1440, height: 900 } };
if (ENGINE === 'chrome') launchOpts.channel = 'chrome';
const ctx = await drv.launchPersistentContext(authDir, launchOpts);
const page = ctx.pages()[0] || await ctx.newPage();
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 }).catch((e) => console.log('nav', e.message));
console.log(' >> If a Cloudflare "verify you are human" check shows, CLICK IT in the window. <<');
let ready = false;
for (let i = 0; i < 80; i++) { // up to ~4 min
await page.waitForTimeout(3000);
if (await page.$('#new-password').catch(() => null)) { ready = true; break; }
const t = await page.title().catch(() => '');
if (i % 4 === 0) console.log(` waiting for reset form... (${(i + 1) * 3}s, title="${t.slice(0, 40)}")`);
}
console.log(ready ? ' reset form ready' : ' reset form never appeared — Cloudflare not cleared on this engine.');
if (ready) {
await page.waitForTimeout(1500);
// token-reset modal only needs the two password fields + SAVE (do NOT touch #password-reset-email).
const fill = async (sel, val, label) => {
try { await page.locator(sel).first().fill(val, { timeout: 15000 }); console.log(`${label}: filled`); }
catch (e) { console.log(`${label}: ${e.message.slice(0, 45)}`); }
};
await fill('#new-password', pw, 'new-password');
await fill('#new-password-confirm', pw, 'confirm-password');
// click the SAVE button inside the visible reset modal
const save = await page.locator('button:has-text("SAVE")').first();
if (await save.count().catch(() => 0)) { await save.click({ timeout: 8000 }).catch((e) => console.log('save click:', e.message.slice(0, 40))); console.log('SAVE clicked'); }
else { await page.keyboard.press('Enter').catch(() => {}); }
await page.waitForTimeout(6000);
const body = await page.evaluate(() => (document.body ? document.body.innerText : '')).catch(() => '');
console.log('post-save url:', page.url());
console.log('result:', body.replace(/\s+/g, ' ').slice(0, 300));
await page.screenshot({ path: 'probe-reset.png' }).catch(() => {});
}
await page.waitForTimeout(1500).catch(() => {});
await ctx.close().catch(() => {});