Skip to content

Commit

Permalink
Merge pull request #173 from cachho/feat/AddNewAgents
Browse files Browse the repository at this point in the history
feat: add new agents
  • Loading branch information
cachho authored Sep 25, 2024
2 parents fbd8a1e + 1bb57f6 commit 085b223
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 20 deletions.
10 changes: 10 additions & 0 deletions manifest-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"*://*.cssbuy.com/*",
"*://*.pandabuy.com/*",
"*://*.hagobuy.com/*",
"*://*.hegobuy.com/*",
"*://*.kameymall.com/*",
"*://*.ezbuycn.com/*",
"*://*.cnfans.com/*",
Expand All @@ -40,6 +41,10 @@
"*://*.joyabuy.com/*",
"*://*.orientdig.com/*",
"*://*.oopbuy.com/*",
"*://*.lovegobuy.com/*",
"*://*.blikbuy.com/*",
"*://*.ponybuy.com/*",
"*://*.panglobalbuy.com/*",
"*://*.basetao.com/*",
"*://*.taobao.com/*",
"*://*.weidian.com/*",
Expand All @@ -59,6 +64,7 @@
"*://*.superbuy.com/*",
"*://*.sugargoo.com/*",
"*://*.hagobuy.com/*",
"*://*.hegobuy.com/*",
"*://*.cssbuy.com/*",
"*://*.pandabuy.com/*",
"*://*.kameymall.com/*",
Expand All @@ -74,6 +80,10 @@
"*://*.joyabuy.com/*",
"*://*.orientdig.com/*",
"*://*.oopbuy.com/*",
"*://*.lovegobuy.com/*",
"*://*.blikbuy.com/*",
"*://*.ponybuy.com/*",
"*://*.panglobalbuy.com/*",
"https://*.reparchive.com/*",
"https://*.jadeship.com/*"
],
Expand Down
17 changes: 16 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"*://*.cssbuy.com/*",
"*://*.pandabuy.com/*",
"*://*.hagobuy.com/*",
"*://*.hegobuy.com/*",
"*://*.kameymall.com/*",
"*://*.ezbuycn.com/*",
"*://*.cnfans.com/*",
Expand All @@ -35,6 +36,10 @@
"*://*.joyabuy.com/*",
"*://*.orientdig.com/*",
"*://*.oopbuy.com/*",
"*://*.lovegobuy.com/*",
"*://*.blikbuy.com/*",
"*://*.ponybuy.com/*",
"*://*.panglobalbuy.com/*",
"*://*.taobao.com/*",
"*://*.weidian.com/*",
"*://*.1688.com/*",
Expand All @@ -56,6 +61,7 @@
"*://*.cssbuy.com/*",
"*://*.pandabuy.com/*",
"*://*.hagobuy.com/*",
"*://*.hegobuy.com/*",
"*://*.kameymall.com/*",
"*://*.ezbuycn.com/*",
"*://*.cnfans.com/*",
Expand All @@ -69,6 +75,10 @@
"*://*.joyabuy.com/*",
"*://*.orientdig.com/*",
"*://*.oopbuy.com/*",
"*://*.lovegobuy.com/*",
"*://*.blikbuy.com/*",
"*://*.ponybuy.com/*",
"*://*.panglobalbuy.com/*",
"*://*.taobao.com/*",
"*://*.weidian.com/*",
"*://*.1688.com/*",
Expand All @@ -88,6 +98,7 @@
"*://*.cssbuy.com/*",
"*://*.pandabuy.com/*",
"*://*.hagobuy.com/*",
"*://*.hegobuy.com/*",
"*://*.kameymall.com/*",
"*://*.ezbuycn.com/*",
"*://*.cnfans.com/*",
Expand All @@ -100,7 +111,11 @@
"*://*.hubbuycn.com/*",
"*://*.joyabuy.com/*",
"*://*.orientdig.com/*",
"*://*.oopbuy.com/*"
"*://*.oopbuy.com/*",
"*://*.lovegobuy.com/*",
"*://*.blikbuy.com/*",
"*://*.ponybuy.com/*",
"*://*.panglobalbuy.com/*"
],
"permissions": ["storage", "webNavigation", "scripting"]
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"cn-links": "^1.19.0",
"cn-links": "^1.22.0",
"html-webpack-plugin": "^5.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Binary file added public/agent_logos/blikbuy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/agent_logos/hegobuy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/agent_logos/lovegobuy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/agent_logos/panglobalbuy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/agent_logos/ponybuy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/__tests__/validateRegisterPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('validateRegisterPage', () => {
cssbuy: 'https://m.cssbuy.com/?go=user&action=register',
sugargoo: 'https://www.sugargoo.com/#/login/login?redirect=/home/home',
hagobuy: 'https://www.hagobuy.com/register',
hegobuy: 'https://www.hegobuy.com/register',
ezbuycn: 'https://ezbuycn.com/reg.aspx',
cnfans: 'https://cnfans.com/register/',
kameymall: 'https://www.kameymall.com/login?loginType=1',
Expand All @@ -24,6 +25,10 @@ describe('validateRegisterPage', () => {
joyabuy: 'https://joyabuy.com/register/',
orientdig: 'https://orientdig.com/register/',
oopbuy: 'https://www.oopbuy.com/register',
lovegobuy: 'https://www.lovegobuy.com/login/signup',
blikbuy: 'https://blikbuy.com/?go=user&action=register',
ponybuy: 'https://www.ponybuy.com/en-gb/register',
panglobalbuy: 'https://panglobalbuy.com/#/register',
};

agents.forEach((agent) => {
Expand Down
6 changes: 6 additions & 0 deletions src/data/redirectListenerUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const redirectListenerUrls: Array<{ hostSuffix: string }> = [
{ hostSuffix: 'cssbuy.com' },
{ hostSuffix: 'pandabuy.com' },
{ hostSuffix: 'hagobuy.com' },
{ hostSuffix: 'hegobuy.com' },
{ hostSuffix: 'kameymall.com' },
{ hostSuffix: 'ezbuycn.com' },
{ hostSuffix: 'cnfans.com' },
Expand All @@ -17,4 +18,9 @@ export const redirectListenerUrls: Array<{ hostSuffix: string }> = [
{ hostSuffix: 'hubbuycn.com' },
{ hostSuffix: 'joyabuy.com' },
{ hostSuffix: 'orientdig.com' },
{ hostSuffix: 'oopbuy.com' },
{ hostSuffix: 'lovegobuy.com' },
{ hostSuffix: 'blikbuy.com' },
{ hostSuffix: 'panglobalbuy.com' },
{ hostSuffix: 'ponybuy.com' },
];
11 changes: 11 additions & 0 deletions src/lib/addPadding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function addPadding(targetElement: Element, height = '48px') {
const padding = document.createElement('div');
padding.className = 'ra-ext-padding';
padding.style.height = height;
// Insert padding as the first child of targetElement
if (targetElement.firstChild) {
targetElement.insertBefore(padding, targetElement.firstChild);
} else {
targetElement.appendChild(padding); // Use appendChild if there are no other children
}
}
6 changes: 6 additions & 0 deletions src/lib/getTargetHrefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function getTargetHrefs(settings: Settings) {
'sugargoo.com/index/item',
'cssbuy.com/item',
'hagobuy.com/item',
'hegobuy.com/item',
'weidian.info',
'kameymall.com/purchases/search',
'cnfans.com/product',
Expand All @@ -70,6 +71,11 @@ export function getTargetHrefs(settings: Settings) {
'hubbuycn.com/index/item',
'joyabuy.com/product',
'orientdig.com/product',
'oopbuy.com/product',
'lovegobuy.com/product',
'blikbuy.com/',
'panglobalbuy.com/#/details',
'ponybuy.com/',
]);
}

Expand Down
37 changes: 27 additions & 10 deletions src/lib/placeToolbar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Agent } from 'cn-links';

import type { Settings } from '../models';
import { addPadding } from './addPadding';
import { waitForElement } from './waitForElement';

export const agentsWhereStickyIsNotAStyle: Agent[] = ['hagobuy'];
Expand All @@ -25,16 +26,7 @@ export function placeToolbar(
}
});
waitForElement('.item-page', (targetElement) => {
console.log('target:', targetElement);
const padding = document.createElement('div');
padding.className = 'ra-ext-padding';
padding.style.height = '48px';
// Insert padding as the first child of targetElement
if (targetElement.firstChild) {
targetElement.insertBefore(padding, targetElement.firstChild);
} else {
targetElement.appendChild(padding); // Use appendChild if there are no other children
}
addPadding(targetElement);
});
} else if (agent === 'pandabuy' && settings.stickyToolbar) {
// Select the target element with the class 'home-fixed'
Expand Down Expand Up @@ -62,6 +54,31 @@ export function placeToolbar(
targetElement.appendChild(elem);
}
});
} else if (agent === 'panglobalbuy') {
const query = '.header_warp';
waitForElement(query, (targetElement) => {
// Check if the target element has a first child
if (targetElement.firstChild) {
// If there is a first child, insert the element before it
targetElement.insertBefore(elem, targetElement.firstChild);
} else {
// If there is no first child, append the element to the target element
targetElement.appendChild(elem);
}
addPadding(targetElement, '60px');
});
} else if (agent === 'hegobuy') {
const query = '.home-fixed';
waitForElement(query, (targetElement) => {
// Check if the target element has a first child
if (targetElement.firstChild) {
// If there is a first child, insert the element before it
targetElement.insertBefore(elem, targetElement.firstChild);
} else {
// If there is no first child, append the element to the target element
targetElement.appendChild(elem);
}
});
} else {
body.insertAdjacentElement('afterbegin', elem);
}
Expand Down
16 changes: 15 additions & 1 deletion src/lib/validateRegisterPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function validateRegisterPage(
newLocation.pathname.startsWith('/index/user/register')
);
}
if (agent === 'hagobuy') {
if (agent === 'hagobuy' || agent === 'hegobuy') {
return location.pathname.startsWith('/register');
}
if (agent === 'kameymall') {
Expand Down Expand Up @@ -63,5 +63,19 @@ export function validateRegisterPage(
if (agent === 'oopbuy') {
return location.pathname.startsWith('/register');
}
if (agent === 'lovegobuy') {
return location.pathname.startsWith('/login/signup');
}
if (agent === 'blikbuy') {
const params = new URLSearchParams(location.search);
return location.pathname === '/' && params.get('action') === 'register';
}
if (agent === 'ponybuy') {
return location.pathname.includes('/register');
}
if (agent === 'panglobalbuy') {
return location.href.includes('/register');
}

return false;
}

0 comments on commit 085b223

Please sign in to comment.