This commit is contained in:
HF101 2025-07-28 15:40:22 +08:00
parent 2bafb403ea
commit 0059f8246b
7 changed files with 81 additions and 25 deletions

View File

@ -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

View File

@ -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",

37
pnpm-lock.yaml generated
View File

@ -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:

View File

@ -110,7 +110,7 @@ class AmazonPageWorkerImpl
options: Parameters<typeof this.runDetailPageTask>[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,6 +172,7 @@ class AmazonPageWorkerImpl
}
//#endregion
//#region Fetch Goods' Images
if (image) {
const imageUrls = await injector.getImageUrls();
imageUrls.length > 0 &&
(await this.emit('item-images-collected', {
@ -179,6 +180,7 @@ class AmazonPageWorkerImpl
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<void> {
const { progress } = options;
const remains = [...asins];

View File

@ -28,12 +28,14 @@ export class BaseInjector {
protected async screenshot(
data: ProtocolMap['dom-to-image']['data'],
): Promise<ProtocolMap['dom-to-image']['return']> {
): Promise<ProtocolMap['dom-to-image']['return'] | null> {
const sender = await this.getMessageSender();
return sender!.sendMessage('dom-to-image', data, {
return sender!
.sendMessage('dom-to-image', data, {
context: 'content-script',
tabId: this._tab.id!,
});
})
.catch((_) => null);
}
protected run<T, P extends Record<string, unknown>>(

View File

@ -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"
>
<n-form-item label="Image:">
<n-switch v-model:value="detailWorkerSettings.image" />
</n-form-item>
<n-form-item label="Aplus:">
<n-switch v-model:value="detailWorkerSettings.aplus" />
</n-form-item>

View File

@ -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,
});