-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
executable file
·140 lines (133 loc) · 5 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
chrome.topSites.get(function (top){
if(top){
top = top.splice(0, 7)
var str = '<ul>'
top.forEach(data=>{
var name = data.title;
var link = data.url;
str += `<li><a target="_blank" href="${link}">${name}</a></li>`
})
document.getElementById('topSites').innerHTML = str;
}
})
var topBtnSel = document.getElementById('topShowBtn')
if(topBtnSel) {
topBtnSel.addEventListener('mouseover', function(){
var element = document.getElementById("topSites");
element.classList.toggle("showHide");
})
topBtnSel.addEventListener('click', function(){
var element = document.getElementById("topSites");
element.classList.toggle("showHide");
})
}
var set = document.getElementById('plus')
if(set) {
set.addEventListener('click', function(){
var element1 = document.getElementById("main-body");
var element2 = document.getElementById("settings");
var element = document.getElementById("topSites");
element.classList.add("showHide");
element1.classList.toggle("showHide");
element2.classList.toggle("showHide");
})
}
var sel = document.getElementById("setLogo")
if(sel){
sel.addEventListener('change',srcIcon)
}
function srcIcon(){
var opt = sel.options[sel.selectedIndex].value;
if(opt == "iconone"){
document.getElementById("customLogo").src ="images/img_1.png"
}
if (opt == "icontwo"){
document.getElementById("customLogo").src ="images/img_2.png"
}
if (opt == "iconthree"){
document.getElementById("customLogo").src ="images/img_3.png"
}
if (opt == "iconfour"){
document.getElementById("customLogo").src ="images/img_4.png"
}
if (opt == "iconfive"){
document.getElementById("customLogo").src ="images/img_5.png"
}
}
var saved = document.getElementById('subm')
if(saved){
saved.addEventListener('click',function(){
var cmdLink = document.getElementById("setLogo")
var isLinAvail = document.getElementById("cusIcLink").value
var pic = cmdLink.options[cmdLink.selectedIndex].value;
var newLink = document.getElementById("linkNew").value
newLink = 'http://' + newLink
if(pic === "iconone"){
chrome.storage.sync.set({iconone: newLink}, function() {});
if(isLinAvail !== " " || isLinAvail !== undefined){
chrome.storage.sync.set({iconLogo1: isLinAvail}, function() {});
}
}
if(pic === "icontwo"){
chrome.storage.sync.set({icontwo: newLink}, function() {});
if(isLinAvail !== " " || isLinAvail !== undefined){
chrome.storage.sync.set({iconLogo2: isLinAvail}, function() {});
}
}
if(pic === "iconthree"){
chrome.storage.sync.set({iconthree: newLink}, function() {});
if(isLinAvail !== " " || isLinAvail !== undefined){
chrome.storage.sync.set({iconLogo3: isLinAvail}, function() {});
}
}
if(pic === "iconfour"){
chrome.storage.sync.set({iconfour: newLink}, function() {});
if(isLinAvail !== " " || isLinAvail !== undefined){
chrome.storage.sync.set({iconLogo4: isLinAvail}, function() {});
}
}
if(pic === "iconfive"){
chrome.storage.sync.set({iconfive: newLink}, function() {});
if(isLinAvail !== " " || isLinAvail !== undefined){
chrome.storage.sync.set({iconLogo5: isLinAvail}, function() {});
}
}
})
}
chrome.storage.sync.get(['iconone','icontwo','iconthree', 'iconfour', 'iconfive','iconLogo1','iconLogo2', 'iconLogo3', 'iconLogo4', 'iconLogo5'], function(result) {
if(result.iconone){
document.getElementById('icon1').href = result.iconone
document.getElementById('icon1').title = result.iconone
}
if(result.icontwo){
document.getElementById('icon2').href = result.icontwo
document.getElementById('icon2').title = result.icontwo
}
if(result.iconthree){
document.getElementById('icon3').href = result.iconthree
document.getElementById('icon3').title = result.iconthree
}
if(result.iconfour){
document.getElementById('icon4').href = result.iconfour
document.getElementById('icon4').title = result.iconfour
}
if(result.iconfive){
document.getElementById('icon5').href = result.iconfive
document.getElementById('icon5').title = result.iconfive
}
if(result.iconLogo1){
document.getElementById('iconLogo1').src = result.iconLogo1
}
if(result.iconLogo2){
document.getElementById('iconLogo2').src = result.iconLogo2
}
if(result.iconLogo3){
document.getElementById('iconLogo3').src = result.iconLogo3
}
if(result.iconLogo4){
document.getElementById('iconLogo4').src = result.iconLogo4
}
if(result.iconLogo5){
document.getElementById('iconLogo5').src = result.iconLogo5
}
});