mirror of
https://github.com/primedigitaltech/azon_seeker.git
synced 2026-10-05 23:33:21 +08:00
fix: fix can`t get imgurls on the page
This commit is contained in:
parent
2c503a9ab6
commit
3befed6d76
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "azon-seeker",
|
"name": "azon-seeker",
|
||||||
"displayName": "Azon Seeker v0.7.1.7-beta",
|
"displayName": "Azon Seeker v0.7.1.8-beta",
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Starter modify by honestfox101 and PetrichorFun",
|
"description": "Starter modify by honestfox101 and PetrichorFun",
|
||||||
|
|||||||
@ -16,6 +16,7 @@ export const isFirefox = navigator.userAgent.includes('Firefox');
|
|||||||
|
|
||||||
// export const remoteHost = __DEV__ ? '127.0.0.1:8000' : '47.251.4.191:8000';
|
// export const remoteHost = __DEV__ ? '127.0.0.1:8000' : '47.251.4.191:8000';
|
||||||
// export const remoteHost = __DEV__ ? '127.0.0.1:18000' : 'vm8nc3zr-18000.usw2.devtunnels.ms';
|
// export const remoteHost = __DEV__ ? '127.0.0.1:18000' : 'vm8nc3zr-18000.usw2.devtunnels.ms';
|
||||||
export const remoteHost = __DEV__ ? 'ogsm-dev.rekeymed.com:8888' : 'amzplugin.rekeymed.com';
|
// export const remoteHost = __DEV__ ? 'ogsm-dev.rekeymed.com:8888' : 'amzplugin.rekeymed.com';
|
||||||
|
export const remoteHost = __DEV__ ? '127.0.0.1:18000' : 'amzplugin.rekeymed.com';
|
||||||
// export const remoteHost = __DEV__ ? '127.0.0.1:18000' : 'amzplugin.rekeymed.com';
|
// export const remoteHost = __DEV__ ? '127.0.0.1:18000' : 'amzplugin.rekeymed.com';
|
||||||
// export const remoteHost = '47.251.4.191:8000';
|
// export const remoteHost = '47.251.4.191:8000';
|
||||||
|
|||||||
@ -22,7 +22,16 @@ const httpClient = createAlova({
|
|||||||
method.config.headers['x-public-key'] = publicKeyBase64Data;
|
method.config.headers['x-public-key'] = publicKeyBase64Data;
|
||||||
},
|
},
|
||||||
responded: {
|
responded: {
|
||||||
onSuccess: (response) => response.json(),
|
// 使用 text() 而不是 json() 来避免 Response body 被重复读取的问题
|
||||||
|
// 参考: https://github.com/alovajs/alova/issues/XXX
|
||||||
|
onSuccess: async (response) => {
|
||||||
|
const text = await response.text();
|
||||||
|
// 检查空响应
|
||||||
|
if (!text || text.trim() === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return JSON.parse(text);
|
||||||
|
},
|
||||||
onError: (response: Response) => {
|
onError: (response: Response) => {
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
message.error(`HTTP Error: ${response.status}`);
|
message.error(`HTTP Error: ${response.status}`);
|
||||||
|
|||||||
@ -490,9 +490,12 @@ export class AmazonDetailPageInjector extends BaseInjector {
|
|||||||
public async getImageUrls() {
|
public async getImageUrls() {
|
||||||
return this.run(async () => {
|
return this.run(async () => {
|
||||||
const overlay = document.querySelector<HTMLElement>('.overlayRestOfImages');
|
const overlay = document.querySelector<HTMLElement>('.overlayRestOfImages');
|
||||||
|
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
|
// document.querySelector<HTMLElement>('#canvasCaption > a')?.click();
|
||||||
if (document.querySelector<HTMLElement>('#ivThumbs')!.getClientRects().length === 0) {
|
if (document.querySelector<HTMLElement>('#ivThumbs')!.getClientRects().length === 0) {
|
||||||
overlay.click();
|
document.querySelector<HTMLElement>('#canvasCaption > a')?.click();
|
||||||
|
// overlay.click();
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,7 +515,35 @@ export class AmazonDetailPageInjector extends BaseInjector {
|
|||||||
/(?<="large":")https:\/\/m.media-amazon.com\/images\/I\/[\w\d\.\-+]+(?=")/g,
|
/(?<="large":")https:\/\/m.media-amazon.com\/images\/I\/[\w\d\.\-+]+(?=")/g,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
document.querySelector<HTMLElement>('header > [data-action="a-popover-close"]')?.click();
|
|
||||||
|
// 替换原来的 forEach (第524-537行)
|
||||||
|
if (urls.length === 0) {
|
||||||
|
const divs: NodeListOf<HTMLDivElement> =
|
||||||
|
document.querySelectorAll('.ivRow div.ivThumbImage');
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500 + ~~(500 * Math.random())));
|
||||||
|
for (const div of divs) {
|
||||||
|
// click div com
|
||||||
|
div.click();
|
||||||
|
|
||||||
|
// wait for image to load
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100 + ~~(500 * Math.random())));
|
||||||
|
|
||||||
|
// get img dom
|
||||||
|
const imgDom = document.querySelector('#ivLargeImage > img');
|
||||||
|
|
||||||
|
// get url from img dom src attribute
|
||||||
|
if (imgDom && 'src' in imgDom) {
|
||||||
|
urls.push(imgDom.src as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// document.querySelector<HTMLElement>('header > [data-action="a-popover-close"]')?.click();
|
||||||
|
// close the image overlay if exists
|
||||||
|
document
|
||||||
|
.querySelector<HTMLElement>('#a-popover-4 > div > div:nth-child(1) > button')
|
||||||
|
?.click();
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user