Skip to content

Commit

Permalink
Merge pull request #87 from cachho/feat/ShortenedHagobuy
Browse files Browse the repository at this point in the history
feat: shortened hagobuy
  • Loading branch information
cachho authored Aug 20, 2023
2 parents cc10d77 + 7f48af8 commit ee4ad6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/findLinksOnPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function findLinksOnPage(settings: Settings) {
'sugargoo.com/index/item',
'cssbuy.com/item',
'hagobuy.com/item',
'weidian.info',
]);
}

Expand Down
22 changes: 16 additions & 6 deletions src/lib/handleShortenedLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export async function handleShortenedLink(
link: HTMLAnchorElement,
settings: Settings
): Promise<URL | null> {
if (!settings.onlineFeatures) {
return null;
}
if (
(link.hostname === 'pandabuy.page.link' ||
link.hostname === 'pandabuy.allapp.link') &&
settings.onlineFeatures
link.hostname === 'pandabuy.page.link' ||
link.hostname === 'pandabuy.allapp.link'
) {
const url = `https://api.reparchive.com/convert/pandabuy?url=${encodeURIComponent(
link.href
Expand All @@ -17,21 +19,29 @@ export async function handleShortenedLink(
if (response && response.data) {
return new URL(response.data.url);
}
} else if (link.hostname === 'qr.1688.com' && settings.onlineFeatures) {
} else if (link.hostname === 'weidian.info') {
const url = `https://api.reparchive.com/convert/hagobuy/${link.pathname.slice(
1
)}`;
const response: ApiResponse<{ url: string }> = await fetchData(url);
if (response && response.data) {
return new URL(response.data.url);
}
} else if (link.hostname === 'qr.1688.com') {
const url = `https://api.reparchive.com/convert/1688/${link.pathname.slice(
3
)}`;
const response: ApiResponse<{ url: string }> = await fetchData(url);
if (response && response.data) {
return new URL(response.data.url);
}
} else if (link.hostname === 'k.youshop10.com' && settings.onlineFeatures) {
} else if (link.hostname === 'k.youshop10.com') {
const url = `https://api.reparchive.com/convert/kyoushop${link.pathname}`;
const response: ApiResponse<{ url: string }> = await fetchData(url);
if (response && response.data) {
return new URL(response.data.url);
}
} else if (link.hostname === 'm.tb.cn' && settings.onlineFeatures) {
} else if (link.hostname === 'm.tb.cn') {
const url = `https://api.reparchive.com/convert/taobao${link.pathname}`;
const response: ApiResponse<{ url: string }> = await fetchData(url);
if (response && response.data) {
Expand Down

0 comments on commit ee4ad6e

Please sign in to comment.