-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpopup.js
39 lines (33 loc) · 1.25 KB
/
popup.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
// Initialize butotn with users's prefered color
let changeColor = document.getElementById("changeColor");
// chrome.storage.sync.get("color", ({ color }) => {
// changeColor.style.backgroundColor = color;
// });
// When the button is clicked, inject setPageBackgroundColor into current page
changeColor.addEventListener("click", async () => {
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: setPageBackgroundColor,
});
});
// The body of this function will be execuetd as a content script inside the
// current page
function setPageBackgroundColor() {
document.querySelector('video').autoplay=true
document.querySelector('video').play()
document.querySelector('video').playbackRate=10
document.querySelector('video').addEventListener("ended", () => {
let currentEle = document.getElementsByClassName("resource-item resource-item-train")
for (let i = 0; i < currentEle.length; i ++) {
let isEnded = currentEle[i].getElementsByClassName("index-module_progress2_1v4wk").length
if (isEnded == 0) {
currentEle[i].click()
break;
}
}
setTimeout(() => {
setPageBackgroundColor()
}, 1000)
})
}