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>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { JSDOM } from 'jsdom';
|
|
import { collectAmazonDetailImageUrls } from '../src/page-worker/web-injectors/amazon-detail-images';
|
|
|
|
async function runWithHtml(html: string) {
|
|
const dom = new JSDOM(html, { url: 'https://www.amazon.com/dp/B0DMNDL5NH' });
|
|
const previousDocument = globalThis.document;
|
|
const previousMouseEvent = globalThis.MouseEvent;
|
|
Object.assign(globalThis, {
|
|
document: dom.window.document,
|
|
MouseEvent: dom.window.MouseEvent,
|
|
});
|
|
try {
|
|
return await collectAmazonDetailImageUrls();
|
|
} finally {
|
|
Object.assign(globalThis, {
|
|
document: previousDocument,
|
|
MouseEvent: previousMouseEvent,
|
|
});
|
|
dom.window.close();
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const scriptUrls = await runWithHtml(`
|
|
<script>
|
|
window.imageData = {
|
|
"colorImages": {
|
|
"initial": [
|
|
{"hiRes":"https://m.media-amazon.com/images/I/first._AC_SL1500_.jpg","large":"https://m.media-amazon.com/images/I/first-large.jpg"},
|
|
{"hiRes":"https:\\/\\/m.media-amazon.com\\/images\\/I\\/second._AC_SL1500_.jpg","large":"https://m.media-amazon.com/images/I/second-large.jpg"}
|
|
]
|
|
}
|
|
};
|
|
</script>
|
|
`);
|
|
assert.deepEqual(scriptUrls, [
|
|
'https://m.media-amazon.com/images/I/first._AC_SL1500_.jpg',
|
|
'https://m.media-amazon.com/images/I/second._AC_SL1500_.jpg',
|
|
]);
|
|
|
|
const landingUrl = 'https://m.media-amazon.com/images/I/landing._AC_SL1500_.jpg';
|
|
const landingUrls = await runWithHtml(
|
|
`<img id="landingImage" data-old-hires="${landingUrl}" data-a-dynamic-image="{}">`,
|
|
);
|
|
assert.deepEqual(landingUrls, [landingUrl]);
|
|
|
|
console.log('Amazon detail image parser tests passed.');
|
|
}
|
|
|
|
void main();
|