-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproviders.js
53 lines (51 loc) · 1.04 KB
/
providers.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const PROVIDERS = [
{
name: "Continente",
url: "continente.pt",
selectors: {
productName: ".product-name",
ratingResult: ".product-name",
},
},
{
name: "Auchan",
url: "auchan.pt",
selectors: {
productName: ".product-name",
ratingResult: ".product-name",
},
},
{
name: "EL Corte Ingles",
url: "elcorteingles.pt",
selectors: {
productName: ".breadcrumbs-item span",
ratingResult: ".pdp-title a span",
},
},
{
name: "Minipreço",
url: "minipreco.pt",
selectors: {
productName: ".product-name h1",
ratingResult: ".product-name h1",
},
},
];
const currentProvider = PROVIDERS.find((provider) =>
location.href.includes(provider.url)
);
if (currentProvider) {
chrome.runtime.sendMessage(
{
name: getName(currentProvider.selectors.productName),
provider: currentProvider,
},
function (response) {
injectRating(
currentProvider.selectors.ratingResult,
getInfo(response.html)
);
}
);
}