-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
executable file
·98 lines (89 loc) · 3.79 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function bulleStore(e){
var infobulles;
var id = parseInt(this.id.replace("check-alert", ""));
var checked = this.checked;
chrome.storage.local.get('infobulles', function(results){
infobulles = results.infobulles;
if(checked) {
infobulles[id] = true;
}
else {
infobulles[id] = false;
}
chrome.storage.local.set({
'infobulles': infobulles,
}
);
});
}
function main() {
var messages = [
"Ce site n'est pas traité par l'outil.",
"Un site parodique/satyrique selon LeMonde. Peut être le seul cas utile ou légitime de l'outil, et encore, c'est tellement arbitraire.",
"Ce site a la chance d'être qualifié de complotiste dans le code de l'application de LeMonde ! Une démarquation qui mérite le détour.",
"Ce site est mal perçu par l'équipe du journal LeMonde. C'est probablement intéréssant, allez y !",
"Ce site a reçu la bénédiction de LeMonde. Soyez prudent, prenez en à petite dose."
]
var colors = [
"#A2A9AE", "#F5A725", "#468847", "#129AF0", "#D50303"
];
var background = chrome.extension.getBackgroundPage();
console.log(background);
if(background.debunker == true) {
document.querySelector(".content #site-name").innerHTML = background.site_actif;
document.querySelector("#notule").innerHTML = background.notule;
document.querySelector("#our-opinion").style["color"] = colors[background.note];
document.querySelector("#our-opinion").innerHTML = messages[background.note];
document.querySelector("#notule").innerHTML = background.notule;
document.querySelector("#decodex-window").style.display = "block";
document.querySelector("#verif").classList.remove("active");
document.querySelector("#decodex-window").classList.add('active');
document.querySelector("#more-info").href = "http://www.les-crises.fr/quand-le-monde-ressuscite-l-index-de-l-eglise-catholique/";
}
else {
document.querySelector("#verif").style.display = "block";
document.querySelector("#decodex-window").classList.remove('active');
document.querySelector("#verif").classList.add("active");
document.querySelector("#decodex-window").style.display = "none";
}
var params = document.querySelector("#params");
params.addEventListener("click", function(){
var parameters = document.querySelector("#parameters");
if(params.classList.contains("active-p")){
params.classList.remove("active-p");
parameters.style.display = "none";
document.querySelector(".active").style.display = "block";
}
else {
params.classList.add("active-p");
document.querySelector(".active").style.display = "none";
parameters.style.display = "block";
}
});
chrome.storage.local.get('infobulles', function(results){
for(var i=0;i<5;i++){
if(results.infobulles[i] == true){
document.getElementById("check-alert" + i).checked = true;
}
else {
document.getElementById("check-alert" + i).checked = false;
}
}
});
document.querySelector('#more-info').addEventListener('click', function(e){
if(e.target.href!==undefined){
chrome.tabs.create({url:e.target.href});
}
e.preventDefault();
window.close();
});
for(var i=0;i<5;i++){
document.querySelector("#alert"+i).style.color = colors[i];
}
}
document.addEventListener('DOMContentLoaded', function () {
main();
for(var i=0;i<5;i++){
document.querySelector('#check-alert'+i).addEventListener('click', bulleStore);
}
});