-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAverageGrowth.js
More file actions
45 lines (45 loc) · 2.48 KB
/
AverageGrowth.js
File metadata and controls
45 lines (45 loc) · 2.48 KB
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
var node = document.createElement("DIV");
var dailyGrowth = document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[0].innerText;
var weeklyGrowth = document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[1].innerText;
var monthlyGrowth = document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[2].innerText;
dailyGrowth = dailyGrowth.replaceAll("One day","");
dailyGrowth = dailyGrowth.replaceAll(/(\r\n|\n|\r)/gm, "");
dailyGrowth = dailyGrowth.replaceAll(" ", "");
dailyGrowth = dailyGrowth.replaceAll(",", "");
dailyGrowth = dailyGrowth.replaceAll("↑",'');
dailyGrowth = dailyGrowth.replaceAll("↓",'');
weeklyGrowth = weeklyGrowth.replaceAll("One week","");
weeklyGrowth = weeklyGrowth.replaceAll(/(\r\n|\n|\r)/gm, "");
weeklyGrowth = weeklyGrowth.replaceAll(" ", "");
weeklyGrowth = weeklyGrowth.replaceAll(",",'');
weeklyGrowth = weeklyGrowth.replaceAll("↑",'');
weeklyGrowth = weeklyGrowth.replaceAll("↓",'');
monthlyGrowth = monthlyGrowth.replaceAll("One month","");
monthlyGrowth = monthlyGrowth.replaceAll(/(\r\n|\n|\r)/gm, "");
monthlyGrowth = monthlyGrowth.replaceAll(" ", "");
monthlyGrowth = monthlyGrowth.replaceAll(",",'');
monthlyGrowth = monthlyGrowth.replaceAll("↑",'');
monthlyGrowth = monthlyGrowth.replaceAll("↓",'');
if(document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[0].children[1].classList.value == "bottom red") {
dailyGrowth = -dailyGrowth;
}
if(document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[1].children[1].classList.value == "bottom red") {
weeklyGrowth = -weeklyGrowth;
}
if(document.getElementsByClassName("boxes-2")[0].children[0].getElementsByClassName("left")[2].children[1].classList.value == "bottom red") {
monthlyGrowth = -monthlyGrowth;
}
var averageGrowth = Math.round((+dailyGrowth + +weeklyGrowth/7 + +monthlyGrowth/30)/3);
var arrow = document.createElement("i");
if(averageGrowth<0) {
arrow.setAttribute("class","ui-market-down red");
node.setAttribute("class","prev-value red");
} else {
arrow.setAttribute("class","ui-market-up green");
node.setAttribute("class","prev-value green");
}
document.getElementsByClassName("section-title")[1].appendChild(arrow);
averageGrowth = averageGrowth.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
var textnode = document.createTextNode(averageGrowth);
node.appendChild(textnode);
document.getElementsByClassName("section-title")[1].appendChild(node);