-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
87 lines (76 loc) · 3 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
// alert("popup.js");
// get and set local var for imageToggle
if(!localStorage['imageStatus'] || localStorage['imageStatus']==1){
localStorage['imageStatus'] = 1;
document.getElementById("imageToggle").checked = true;
} else {
document.getElementById("imageToggle").checked = false;
}
// initial run
imageToggle();
// setup imageToggle listener
document.getElementById("imageToggle").onclick = function(){imageToggle();}
// run to switch on and off
function imageToggle(){
if(document.getElementById("imageToggle").checked){
localStorage['imageStatus'] = 1;
//chrome.browserAction.setIcon({path: "images/icon128.png"});
changeImageOpacity(0);
console.log("hide thumbnail");
} else {
localStorage['imageStatus'] = 0;
//chrome.browserAction.setIcon({path: "images/icon128_disabled.png"});
changeImageOpacity(1);
console.log("show thumbnail");
}
}
// function to get elements of .mug and .landscape and change opacity
function changeImageOpacity(opacity){
chrome.tabs.executeScript(null,{
code:"var all = document.getElementsByClassName('landscape');for (var i = 0; i < all.length; i++) {all[i].style.opacity = "+opacity+";}"
});
chrome.tabs.executeScript(null,{
code:"var all = document.getElementsByClassName('mug');for (var i = 0; i < all.length; i++) {all[i].style.opacity = "+opacity+";}"
});
}
// FOR TITLES
// get and set local var for imageToggle
if(!localStorage['titleStatus'] || localStorage['titleStatus']==1){
localStorage['titleStatus'] = 1;
document.getElementById("titleToggle").checked = true;
} else {
document.getElementById("titleToggle").checked = false;
}
// initial run
titleToggle();
// setup titleToggle listener
document.getElementById("titleToggle").onclick = function(){titleToggle();}
// run to switch on and off
function titleToggle(){
if(document.getElementById("titleToggle").checked){
localStorage['titleStatus'] = 1;
//chrome.browserAction.setIcon({path: "titles/icon128.png"});
changeTitleOpacity(0);
console.log("hide thumbnail");
} else {
localStorage['titleStatus'] = 0;
//chrome.browserAction.setIcon({path: "titles/icon128_disabled.png"});
changeTitleOpacity(1);
console.log("show thumbnail");
}
}
// function to get elements of .mug and .landscape and change opacity
function changeTitleOpacity(opacity){
chrome.tabs.executeScript(null,{
code:"var all = document.getElementsByClassName('short-desc');for (var i = 0; i < all.length; i++) {all[i].style.opacity = "+opacity+";}"
});
chrome.tabs.executeScript(null,{
code:"var all = document.getElementsByClassName('collection-carousel-overlay-bottom');for (var i = 0; i < all.length; i++) {all[i].style.opacity = "+opacity+";}"
});
chrome.tabs.executeScript(null,{
code:"var all = document.getElementsByClassName('showmedia-header');for (var i = 0; i < all.length; i++) {all[i].style.opacity = "+opacity+";}"
});
chrome.tabs.executeScript(null,{
code:"document.getElementById('showmedia_about_info').style.opacity = "+opacity+";"
});
}