-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
49 lines (43 loc) · 1.29 KB
/
Copy pathscript.js
File metadata and controls
49 lines (43 loc) · 1.29 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
46
47
48
49
function setSentiment() {
if (document.getElementsByClassName("lv_ratio_light").length == 0) {
interactionMenu =
document.getElementById("menu-container").children[0].children[0]
.children[0];
likes = parseInt(
interactionMenu.children[0].children[0].children[1].ariaLabel
.split(" likes")[0]
.replace(/,/g, ""),
10
);
views = parseInt(
document
.getElementsByClassName(
"view-count style-scope ytd-video-view-count-renderer"
)[0]
.innerHTML.split(" views")[0]
.replace(/,/g, ""),
10
);
chrome.storage.sync.get({ green: 3, yellow: 1 }, function (result) {
green = result.green;
yellow = result.yellow;
likeButton = interactionMenu.children[0];
let light = document.createElement("p");
lv_ratio = (likes / views) * 100;
console.log(lv_ratio, "lv_ratio");
if (lv_ratio > green) {
light.innerHTML = "🟢";
} else if (lv_ratio > yellow) {
light.innerHTML = "🟡";
} else {
light.innerHTML = "🔴";
}
light.style.fontSize = "30px";
light.classList.add("lv_ratio_light");
likeButton.parentNode.insertBefore(light, likeButton);
});
}
}
setInterval(() => {
setSentiment();
}, 1000);