From 0059f8246b9f27be6bd426650f8542d870ed69ba Mon Sep 17 00:00:00 2001 From: HF101 <952508490@qq.com> Date: Mon, 28 Jul 2025 15:40:22 +0800 Subject: [PATCH] Update --- README.md | 24 ++++++++---- package.json | 1 + pnpm-lock.yaml | 37 +++++++++++++++++++ src/page-worker/impls/amazon.ts | 25 +++++++------ src/page-worker/web-injectors/base.ts | 12 +++--- .../views/AmazonEntries/DetailPageEntry.vue | 6 ++- src/storages/amazon.ts | 1 + 7 files changed, 81 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 4f6b45d..8aef4a2 100644 --- a/README.md +++ b/README.md @@ -18,25 +18,34 @@ Azon Seeker is a browser extension designed to collect and manage product inform --- -## Setup +## Get Started ### 1. Prepare Requirements Make sure the following software is installed: -- [Node.js](https://nodejs.org/) +- [Node.js v22+](https://nodejs.org/) - [pnpm](https://pnpm.io/) -### 2. Clone this Repo +### 2. Clone this Repository ```shell git clone https://github.com/primedigitaltech/azon_seeker.git +cd ./azon_seeker/ ``` -### 3. Install the Node Dependencies +### 3. Setup the Webext-bridge + +```shell +cd ./webext-bridge +pnpm i +pnpm build +cd ../ +``` + +### 3. Install the Project's Dependencies ```shell -cd azon_seeker pnpm i ``` @@ -56,12 +65,13 @@ pnpm dev ### 1. Make Sure Setup Successfully -Following the step of setup +Following the step of Get Started to make sure setup successfully. ### 2. Build Project ```shell -pnpm run build +pnpm run build # For Chromium Browser (Microsoft Edge .etc) +pnpm run build-firefox # For Firefox ``` ### 3. Pack Extension diff --git a/package.json b/package.json index db2739d..9f8fd25 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "devDependencies": { "@iconify/json": "^2.2.359", "@types/fs-extra": "^11.0.4", + "@types/gulp-terser": "^1.2.6", "@types/node": "^22.16.4", "@types/webextension-polyfill": "^0.12.3", "@vitejs/plugin-vue": "^6.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7c7c4d3..27f9013 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,9 @@ importers: '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4 + '@types/gulp-terser': + specifier: ^1.2.6 + version: 1.2.6 '@types/node': specifier: ^22.16.4 version: 22.16.4 @@ -1098,6 +1101,12 @@ packages: integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==, } + '@types/gulp-terser@1.2.6': + resolution: + { + integrity: sha512-/4wRi8Edn1ykh1GJdfSN2VvPLWqPP7Y6sG1n5CnRgMCDCfjZ2rLu04vNJK7gAsg+0E5IoDVIpya/mO9es2LsJw==, + } + '@types/jsonfile@6.1.4': resolution: { @@ -1892,6 +1901,12 @@ packages: } engines: { node: '>=20' } + commander@2.20.3: + resolution: + { + integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==, + } + commander@2.9.0: resolution: { @@ -5350,6 +5365,14 @@ packages: } engines: { node: '>=6' } + terser@4.8.1: + resolution: + { + integrity: sha512-4GnLC0x667eJG0ewJTa6z/yXrbLGv80D9Ru6HIpCQmO+Q4PfEtBFi0ObSckqwL6VyQv/7ENJieXHo2ANmdQwgw==, + } + engines: { node: '>=6.0.0' } + hasBin: true + text-table@0.2.0: resolution: { @@ -6628,6 +6651,11 @@ snapshots: '@types/jsonfile': 6.1.4 '@types/node': 22.16.4 + '@types/gulp-terser@1.2.6': + dependencies: + '@types/node': 22.16.4 + terser: 4.8.1 + '@types/jsonfile@6.1.4': dependencies: '@types/node': 22.16.4 @@ -7173,6 +7201,8 @@ snapshots: commander@14.0.0: {} + commander@2.20.3: {} + commander@2.9.0: dependencies: graceful-readlink: 1.0.1 @@ -9241,6 +9271,13 @@ snapshots: inherits: 2.0.4 readable-stream: 3.6.2 + terser@4.8.1: + dependencies: + acorn: 8.15.0 + commander: 2.20.3 + source-map: 0.6.1 + source-map-support: 0.5.21 + text-table@0.2.0: {} thread-stream@2.7.0: diff --git a/src/page-worker/impls/amazon.ts b/src/page-worker/impls/amazon.ts index 3b0775a..ff04a79 100644 --- a/src/page-worker/impls/amazon.ts +++ b/src/page-worker/impls/amazon.ts @@ -110,7 +110,7 @@ class AmazonPageWorkerImpl options: Parameters[1] = {}, ) { //#region Initial Meta Info - const { aplus = false, extra = false } = options; + const { image = false, aplus = false, extra = false } = options; const params = { asin: '', url: '' }; if (entry.match(/^https?:\/\/www\.amazon\.com.*\/dp\/[A-Z0-9]{10}/)) { const [asin] = /\/\/dp\/[A-Z0-9]{10}/.exec(entry)!; @@ -172,13 +172,15 @@ class AmazonPageWorkerImpl } //#endregion //#region Fetch Goods' Images - const imageUrls = await injector.getImageUrls(); - imageUrls.length > 0 && - (await this.emit('item-images-collected', { - asin: params.asin, - imageUrls: Array.from(new Set(imageUrls)), - })); - await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 2 seconds. + if (image) { + const imageUrls = await injector.getImageUrls(); + imageUrls.length > 0 && + (await this.emit('item-images-collected', { + asin: params.asin, + imageUrls: Array.from(new Set(imageUrls)), + })); + await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 2 seconds. + } //#endregion //#region Fetch Top Reviews // const reviews = await injector.getTopReviews(); @@ -190,8 +192,9 @@ class AmazonPageWorkerImpl //#endregion // #region Get APlus Sreen shot if (aplus && (await injector.scanAPlus())) { - const { b64: base64data } = await injector.captureAPlus(); - await this.emit('item-aplus-screenshot-collect', { asin: params.asin, base64data }); + const { b64: base64data } = (await injector.captureAPlus()) || {}; + typeof base64data === 'string' && + (await this.emit('item-aplus-screenshot-collect', { asin: params.asin, base64data })); } // #endregion //#region Get Extra Info @@ -249,7 +252,7 @@ class AmazonPageWorkerImpl public async runDetailPageTask( asins: string[], - options: taskOptionBase & { aplus?: boolean; extra?: boolean } = {}, + options: taskOptionBase & { image?: boolean; aplus?: boolean; extra?: boolean } = {}, ): Promise { const { progress } = options; const remains = [...asins]; diff --git a/src/page-worker/web-injectors/base.ts b/src/page-worker/web-injectors/base.ts index 7f9da81..c65282e 100644 --- a/src/page-worker/web-injectors/base.ts +++ b/src/page-worker/web-injectors/base.ts @@ -28,12 +28,14 @@ export class BaseInjector { protected async screenshot( data: ProtocolMap['dom-to-image']['data'], - ): Promise { + ): Promise { const sender = await this.getMessageSender(); - return sender!.sendMessage('dom-to-image', data, { - context: 'content-script', - tabId: this._tab.id!, - }); + return sender! + .sendMessage('dom-to-image', data, { + context: 'content-script', + tabId: this._tab.id!, + }) + .catch((_) => null); } protected run>( diff --git a/src/sidepanel/views/AmazonEntries/DetailPageEntry.vue b/src/sidepanel/views/AmazonEntries/DetailPageEntry.vue index a9eebf5..a4863f9 100644 --- a/src/sidepanel/views/AmazonEntries/DetailPageEntry.vue +++ b/src/sidepanel/views/AmazonEntries/DetailPageEntry.vue @@ -87,8 +87,7 @@ const launch = async () => { progress: (remains) => { detailAsinInput.value = remains.join('\n'); }, - aplus: detailWorkerSettings.value.aplus, - extra: detailWorkerSettings.value.extra, + ...detailWorkerSettings.value, }); timelines.value.push({ type: 'info', @@ -129,6 +128,9 @@ const handleInterrupt = () => { label-align="center" :show-feedback="false" > + + + diff --git a/src/storages/amazon.ts b/src/storages/amazon.ts index 113092d..848154b 100644 --- a/src/storages/amazon.ts +++ b/src/storages/amazon.ts @@ -11,6 +11,7 @@ export const itemColumnSettings = useWebExtensionStorage< >('itemColumnSettings', new Set(['keywords', 'page', 'rank', 'createTime'])); export const detailWorkerSettings = useWebExtensionStorage('amazon-detail-worker-settings', { + image: true, aplus: false, extra: false, });