-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpricing.js
39 lines (33 loc) · 1.06 KB
/
pricing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
async function loadTWBuyerContent () {
let queryOptions = { active: true, lastFocusedWindow: true };
let [ tab ] = await chrome.tabs.query(queryOptions);
if (!isSupportedHost(tab.url)) {
return
}
const settings = {
"url": "https://search.twbuyer.info/querybyurl",
"method": "POST",
"timeout": 0,
"headers": {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"content-type": "application/json",
},
"data": JSON.stringify({
"url": tab.url
}),
};
$.ajax(settings).done(function (response) {
const iframe = document.getElementById('twBuyerIframe');
if ('ID' in response) {
iframe.src = "https://twbuyer.info/ec_item/" + response.ID
} else {
iframe.src = ''
}
});
}
const supportedDomains = [ "www.momoshop.com.tw", "24h.pchome.com.tw", "tw.buy.yahoo.com" ];
function isSupportedHost (urlString) {
return supportedDomains.includes(new URL(urlString).hostname);
}
window.addEventListener("DOMContentLoaded", loadTWBuyerContent)