-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
56 lines (51 loc) · 2.09 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// if (document.querySelector(".popup")) {
if (document.getElementById("popup")) {
// const button = document.querySelector(".button");
// const circle = document.querySelector(".circle");
const button = document.getElementById("button");
const circle = document.getElementById("circle");
let buttonOn = false;
function invert() {
alert("Mode Extensions")
document.body.style.filter = "invert(1) hue-rotate(180deg)";
// let media = document.querySelectorAll("img, picture, video");
// media.forEach((mediaItem) => {
// mediaItem.style.filter = "invert(1) hue-rotate(180deg)"
// })
document.querySelectorAll("img, picture, video").forEach((mediaItem) => {
mediaItem.style.filter = "invert(1) hue-rotate(180deg)"
})
}
button.addEventListener("click", () => {
if (!buttonOn) {
buttonOn = true;
button.style.animation = "transformToBlue 1s ease-in-out 0s forwards"
circle.style.animation = "moveCircleRight 1s ease-in-out 0s forwards"
// chrome.tabs.executeScript({
// file: 'on.js'
// })
chrome.tabs.query({currentWindow: true, active: true}, function (tabs){
var activeTab = tabs[0]; //insertCSS
chrome.scripting.executeScript({
target: { tabId: activeTab.id },
files: ["on.js"]
});
})
}
else {
buttonOn = false;
button.style.animation = "transformToYellow 1s ease-in-out 0s forwards"
circle.style.animation = "moveCircleLeft 1s ease-in-out 0s forwards"
// chrome.tabs.executeScript({
// file: 'off.js'
// })
chrome.tabs.query({currentWindow: true, active: true}, function (tabs){
var activeTab = tabs[0];
chrome.scripting.executeScript({
target: { tabId: activeTab.id },
files: ["off.js"]
});
})
}
})
}