Skip to content

Commit 1c596f5

Browse files
authored
Merge pull request #207 from cachho/feat/FindQcProvider
feat: findqc qc provider
2 parents dff38b5 + 3587377 commit 1c596f5

File tree

8 files changed

+46
-43
lines changed

8 files changed

+46
-43
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ This extension is an essential quality of life upgrade for you as a customers of
1212

1313
It rewrites all links to your preferred shopping agent. (This includes shopping agent links and direct links to taobao.com and weidian.com.)
1414

15-
Pages become enriched with extra information about the products you're seeing, you get sales stats from www.jadeship.com and QC pics from finds.ly.
15+
Pages become enriched with extra information about the products you're seeing, you get sales stats from www.jadeship.com and QC pics from findqc.com.
1616

1717
This leaves you with a seamless shopping experience, where you don't have to worry about the agents that others use. This extension turns the experience into a "click and buy" experience - like it should be.
1818

1919
Some other features:
2020
- convert links on reddit.com and yupoo.com
21-
- shows you if quality control (QC) pics are available on finds.ly
21+
- shows you if quality control (QC) pics are available on findqc.com
2222
- convert from any agent or marketplace to any agent or no agent (if you prefer)
2323
- handles shortened links (pandabuy.page.link, pandabuy.app.link, weidian.info, l.acbuy.com, etc.)
2424
- countless display options

src/Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const Config = {
66
host: {
77
details: 'https://www.jadeship.com',
88
shortenedLinks: 'https://www.jadeship.com/api',
9-
qc: 'https://www.jadeship.com/api/quota-limited/findsly',
9+
qc: 'https://www.jadeship.com/api/quota-limited/extension/qc',
1010
},
1111
social: {
1212
homepage: 'https://www.jadeship.com/?r=extension',

src/components/Popup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const Popup = () => {
282282
})
283283
}
284284
/>
285-
finds.ly online features
285+
findqc.com online features
286286
<br />
287287
<p>
288288
Online features are provided by Jadeship.com. They include the extra

src/content_script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ async function main(settings: Settings) {
160160
// Add Qc Availability
161161
try {
162162
if (settings.onlineFeaturesQcPhotos) {
163-
const qcAvailable = await promiseQcAvailable;
164-
if (qcAvailable?.some((qc) => qc.qcPhotos.length > 0)) {
163+
const response = await promiseQcAvailable;
164+
if (response?.data && response.data.qcCount > 0) {
165165
addQcElement(link, elem);
166166
}
167167
}

src/lib/api/getQcAvailable.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,31 @@ import { Config } from '../../Config';
44
import type { QcResponse } from '../../models';
55
import { fetchData } from './fetchData';
66

7-
export const findslyMappings = new Map<Marketplace, string>([
8-
['1688', 'ONE_SIX_EIGHT_EIGHT'],
9-
['taobao', 'TAOBAO'],
10-
['weidian', 'WEIDIAN'],
11-
['tmall', 'TAOBAO'],
7+
export const findqcMappings = new Map<Marketplace, string>([
8+
['1688', 'T1688'],
9+
['taobao', 'TB'],
10+
['weidian', 'WD'],
11+
['tmall', 'TB'],
1212
]);
1313

14+
export function generateLink(link: CnLink): string {
15+
return `https://findqc.com/detail/${findqcMappings.get(link.marketplace)}/${
16+
link.id
17+
}`;
18+
}
19+
1420
export async function getQcAvailable(
1521
cnLink: CnLink
1622
): Promise<QcResponse | null> {
17-
const url = `${Config.host.qc}/products/${findslyMappings.get(
18-
cnLink.marketplace
19-
)}/${cnLink.id}/qcPhotos`;
20-
const d = await fetchData(url);
21-
return d;
23+
const data = await fetchData(Config.host.qc, {
24+
method: 'POST',
25+
headers: {
26+
'Content-Type': 'application/json',
27+
},
28+
body: JSON.stringify({
29+
id: cnLink.id,
30+
marketplace: cnLink.marketplace,
31+
}),
32+
});
33+
return data;
2234
}

src/lib/html/addQcElement.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import type { CnLink } from 'cn-links';
22

3-
import { findslyMappings } from '../api/getQcAvailable';
3+
import { generateLink } from '../api/getQcAvailable';
44

55
export function addQcElement(cnLink: CnLink, link: HTMLAnchorElement) {
66
const elem = document.createElement('a');
7-
const url = new URL(
8-
`https://finds.ly/product/${findslyMappings.get(cnLink.marketplace)}/${
9-
cnLink.id
10-
}`
11-
);
7+
const url = new URL(generateLink(cnLink));
128
url.searchParams.set('url', cnLink.as('raw').href);
139
elem.href = url.href;
1410
elem.target = '_blank';

src/models/QcResponse.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
type QcAvailable = {
2-
id: number;
3-
dataSource: {
4-
name: string;
5-
displayName: string;
6-
};
7-
qcPhotos: PhotoSet[];
8-
timeFetched: string;
1+
type ItemQc = {
2+
qcList: {
3+
url: string;
4+
time: number;
5+
format: string;
6+
}[];
7+
findqcDetailUrl: string;
8+
qcCount: number;
99
};
1010

11-
type PhotoSet = {
12-
id: number;
13-
photoUrl: string;
14-
};
15-
16-
export type QcResponse = Array<QcAvailable>;
11+
export type QcResponse = Promise<{
12+
state: number;
13+
msg: string;
14+
data: ItemQc;
15+
}>;

src/toolbar.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111

1212
import { Button } from './components';
1313
import { Config } from './Config';
14-
import { findslyMappings, getQcAvailable } from './lib/api/getQcAvailable';
14+
import { generateLink, getQcAvailable } from './lib/api/getQcAvailable';
1515
import {
1616
addObserver,
1717
handleExceptionElements,
@@ -45,11 +45,7 @@ const BodyElement = (settings: Settings, agent?: Agent) => {
4545
};
4646

4747
const QC = (link: CnLink) => {
48-
const qc = Button(
49-
`https://finds.ly/product/${findslyMappings.get(link.marketplace)}/${
50-
link.id
51-
}`
52-
);
48+
const qc = Button(generateLink(link));
5349
qc.innerText = `📷 QC Pics available`;
5450
return qc;
5551
};
@@ -191,7 +187,7 @@ async function toolbar() {
191187
} else {
192188
try {
193189
const response = await getQcAvailable(currentPage.link);
194-
if (response?.some((qc) => qc.qcPhotos.length > 0)) {
190+
if (response?.data && response?.data.qcCount > 0) {
195191
qcString = QC(currentPage.link).outerHTML;
196192
}
197193
} catch (err) {

0 commit comments

Comments
 (0)