mirror of
https://github.com/primedigitaltech/azon_seeker.git
synced 2026-10-04 14:53:22 +08:00
* feat: add Amazon collection metadata and reliable sync * fix: route extension sync through configured server * chore: release extension v0.7.13 * fix: handle extension ports across BFCache navigation * fix: classify bottom Sponsored Brands video placements * fix: exclude hidden Amazon ad cards * fix: derive Amazon result page from URL * fix: ignore hidden Amazon sponsored products * fix: preserve base Amazon product collection * fix: bind Amazon results to visible page * fix: classify visible Amazon ad formats * fix: wait for lazy Amazon ad modules * perf: reduce Amazon lazy-load scroll stops * fix: classify Amazon sponsored brand and video search ads Co-authored-by: Cursor <cursoragent@cursor.com> * fix: collect Shop by type thematic SP ads via redirect chains without data-asin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: classify sponsored ads across new Amazon templates --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: PetrichorFun <127877748+PetrichorFun@users.noreply.github.com>
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { JSDOM } from 'jsdom';
|
|
import { waitForAmazonDetailPageReady } from '../src/page-worker/web-injectors/amazon-detail-page-ready';
|
|
|
|
const installDom = (html: string, url = 'https://www.amazon.com/dp/B0DMNDL5NH') => {
|
|
const dom = new JSDOM(html, { url });
|
|
Object.defineProperty(dom.window.document, 'readyState', {
|
|
configurable: true,
|
|
value: 'complete',
|
|
});
|
|
Object.assign(globalThis, { document: dom.window.document, window: dom.window });
|
|
Object.assign(dom.window.HTMLElement.prototype, { scrollIntoView: () => undefined });
|
|
return dom;
|
|
};
|
|
|
|
const main = async () => {
|
|
const modernDetail = installDom('<span id="productTitle">Ready product</span>');
|
|
await waitForAmazonDetailPageReady();
|
|
modernDetail.window.close();
|
|
|
|
const legacyDetail = installDom('<span id="title">Legacy product</span>');
|
|
await waitForAmazonDetailPageReady();
|
|
legacyDetail.window.close();
|
|
|
|
const signIn = installDom('<main>Sign in</main>', 'https://www.amazon.com/ap/signin');
|
|
await waitForAmazonDetailPageReady().then(
|
|
() => {
|
|
throw new Error('Sign-in page should fail immediately');
|
|
},
|
|
(error) => {
|
|
if (!String(error).includes('需要重新登录')) throw error;
|
|
},
|
|
);
|
|
signIn.window.close();
|
|
|
|
const captcha = installDom('<input id="captchacharacters">');
|
|
await waitForAmazonDetailPageReady().then(
|
|
() => {
|
|
throw new Error('Captcha page should fail immediately');
|
|
},
|
|
(error) => {
|
|
if (!String(error).includes('验证码')) throw error;
|
|
},
|
|
);
|
|
captcha.window.close();
|
|
|
|
console.log('Amazon detail page readiness tests passed.');
|
|
};
|
|
|
|
void main();
|