-
Notifications
You must be signed in to change notification settings - Fork 1
/
ebayprice.js
42 lines (30 loc) · 1.12 KB
/
ebayprice.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
function init(){
var soldElem = document.getElementById("prcIsum");
if (soldElem == null || soldElem == undefined) return;
var html = document.body.parentElement.innerHTML;
if (!html.includes("\"ended\":true")){
return;
}
var res = /taxExclusivePrice(.*?)",/.exec(html);
if (res != null && res.length>1 && res[0].includes("taxExclusivePrice")){
// check if best offer price is the same
var normPrice = /binPriceOnly(.*?)\",/.exec(html);
var offerPrice = /taxExclusivePrice(.*?)\",/.exec(html);
var finalPrice = res[1].replace("\"","").replace(":\"","");
var finalHtml = "";
if (normPrice[1] == offerPrice[1]){
// we have offer, but same price
finalHtml = " - <span style='color: crimson'> Actual Price: N/A </span>";
}else{
finalHtml = " - <span style='color: green'> Actual Price: " + finalPrice + " ⬇ </span>";
}
if (!soldElem.innerHTML.includes("Actual Price")){
soldElem.innerHTML += finalHtml;
}
}
}
if(document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded',afterDOMLoaded);
} else {
init();
}