-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
70 lines (65 loc) · 2.23 KB
/
content.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
// ask for local storage
// console.log("content.js run");
chrome.runtime.sendMessage({type: "imageStatus"}, function(response) {
// console.log("content.js sending message");
if(response.imageStatus == null){
// console.log("content.js val is null");
return;
} else if(response.imageStatus == 1){
// console.log("content.js val is 1");
changeImageOpacity(0);
} else {
// console.log("content.js val is 0");
changeImageOpacity(1);
}
return;
});
// function to get elements of .mug and .landscape and change opacity
function changeImageOpacity(newOpacity){
// console.log("change opacity running");
var all1 = document.getElementsByClassName('landscape');
for (var i = 0; i < all1.length; i++){
// console.log("hiding a landscape");
all1[i].style.opacity = newOpacity;
}
var all2 = document.getElementsByClassName('mug');
for (var i = 0; i < all2.length; i++){
all2[i].style.opacity = newOpacity;
}
// console.log("change opacity finished");
}
// FOR TITLES
// ask for local storage
// console.log("content.js run");
chrome.runtime.sendMessage({type: "titleStatus"}, function(response) {
// console.log("content.js sending message");
if(response.titleStatus == null){
// console.log("content.js val is null");
return;
} else if(response.titleStatus == 1){
// console.log("content.js val is 1");
changeTitleOpacity(0);
} else {
// console.log("content.js val is 0");
changeTitleOpacity(1);
}
return;
});
// function to get elements of .mug and .landscape and change opacity
function changeTitleOpacity(newOpacity){
// console.log("change opacity running");
var all1 = document.getElementsByClassName('short-desc');
for (var i = 0; i < all1.length; i++){
all1[i].style.opacity = newOpacity;
}
var all2 = document.getElementsByClassName('collection-carousel-overlay-bottom');
for (var i = 0; i < all2.length; i++){
all2[i].style.opacity = newOpacity;
}
var all3 = document.getElementsByClassName('showmedia-header');
for (var i = 0; i < all3.length; i++){
all3[i].style.opacity = newOpacity;
}
document.getElementById('showmedia_about_info').style.opacity = newOpacity;
// console.log("change opacity finished");
}