generated from adatechschool/Projet_Collectif_Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpopup_script.js
47 lines (41 loc) · 1.7 KB
/
popup_script.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
//on attend que la page soit fully loadée pour faire des trucs
document.addEventListener('DOMContentLoaded', function (){
//on écoute le bouton pour créer l'objet
document.querySelector('.increase').addEventListener('click', onclickIncrease, false)
function onclickIncrease(){
chrome.storage.local.set({increase: true})
};
document.querySelector('.decrease').addEventListener('click', onclickDecrease, false)
function onclickDecrease(){
chrome.storage.local.set({decrease: true})
};
const toggle = document.querySelector(".toggle");
toggle.addEventListener("click", onclickToggle, false)
chrome.storage.local.set({toggle: false})
function onclickToggle() {
chrome.storage.local.get(["toggle"]).then((result) => {
if(result.toggle == false) {
function appOn() {
document.querySelector("html").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)";
})
}
appOn()
chrome.storage.local.set({toggle: true})
}
else {
function appOff() {
document.querySelector("html").style.filter = "invert(0) hue-rotate(0deg)";
let media = document.querySelectorAll("img, picture, video");
media.forEach((mediaItem) => {
mediaItem.style.filter = "invert(0) hue-rotate(0deg)";
})
}
appOff()
chrome.storage.local.set({toggle: false})
}
})
}
}, false);