-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
102 lines (89 loc) · 4.17 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
// Pride Theme
document.getElementById("prideTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendPrideTheme"}, function(response){
if (response === "prideSet") {
localStorage.setItem("clickedOnWhichRadioButton", "prideTheme");
}
})
});
});
// Pride And Black Theme
document.getElementById("prideAndBlackTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendPrideAndBlackTheme"}, function(response){
if (response === "prideAndBlackSet") {
localStorage.setItem("clickedOnWhichRadioButton", "prideAndBlackTheme");
}
})
});
});
// Black Theme
document.getElementById("blackTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendBlackTheme"}, function(response) {
if (response === "blackSet") {
localStorage.setItem("clickedOnWhichRadioButton", "blackTheme");
}
})
});
});
// Default Theme
document.getElementById("defaultTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendDefaultTheme"}, function(response) {
if (response === "defaultSet") {
localStorage.setItem("clickedOnWhichRadioButton", "defaultTheme");
}
})
});
});
// turquoiseYellowTheme
document.getElementById("turquoiseYellowTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendTurquoiseYellowTheme"}, function(response) {
if (response === "turquoiseYellowThemeSet") {
localStorage.setItem("clickedOnWhichRadioButton", "turquoiseYellowTheme");
}
})
});
});
// bluePurpleTheme
document.getElementById("bluePurpleTheme").addEventListener("click", () => {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"sendBluePurpleTheme"}, function(response) {
if (response === "bluePurpleThemeSet") {
localStorage.setItem("clickedOnWhichRadioButton", "bluePurpleTheme");
}
})
});
});
if (localStorage.getItem("clickedOnWhichRadioButton") === "blackTheme") {
document.getElementById("blackTheme").checked = true;
} else if (localStorage.getItem("clickedOnWhichRadioButton") === "prideTheme") {
document.getElementById("prideTheme").checked = true;
} else if (localStorage.getItem("clickedOnWhichRadioButton") === "defaultTheme") {
document.getElementById("defaultTheme").checked = true;
} else if (localStorage.getItem("clickedOnWhichRadioButton") === "prideAndBlackTheme") {
document.getElementById("prideAndBlackTheme").checked = true;
} else if (localStorage.getItem("clickedOnWhichRadioButton") === "turquoiseYellowTheme") {
document.getElementById("turquoiseYellowTheme").checked = true;
} else if (localStorage.getItem("clickedOnWhichRadioButton") === "bluePurpleTheme") {
document.getElementById("bluePurpleTheme").checked = true;
}
// Get current url from content.js
document.addEventListener('DOMContentLoaded', function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {type:"popUpClicked"}, function(response) {
console.log(response);
// Only if respons possible let pop be native html, else replace
if (response) {
} else {
document.getElementById("popUpDiv").innerHTML = "";
const hTag = document.createElement("h2");
hTag.appendChild(document.createTextNode("Go to Uni2Work"));
document.getElementById("popUpDiv").appendChild(hTag);
}
})
});
});