forked from github-unicorn/github-unicorn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
60 lines (51 loc) · 1.69 KB
/
script.js
File metadata and controls
60 lines (51 loc) · 1.69 KB
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
button = document.querySelector("#select");
button.addEventListener("click", selectTheme);
button.addEventListener("mouseout", onMouseOut);
button.addEventListener("mouseover", onMouseOver);
if (typeof browser === "undefined") {
var browser = chrome;
}
function onMouseOut() {
chbg("1px solid #3f3d56");
}
function onMouseOver() {
chbg("1px solid #ff63a6");
}
(function () {
let today = new Date();
if (today.getMonth() == 11 && today.getDate() == 25)
document.getElementById('unicorn_logo').src = browser.runtime.getURL('assets/christmas_icon.svg');
if (today.getMonth() == 9 && today.getDate() == 31){
document.getElementById('unicorn_logo').src = browser.runtime.getURL('assets/halloween_icon.svg');
document.getElementsByTagName('body')[0].style.backgroundColor = "#0c0b0b";
document.getElementsByTagName('body')[0].style.color = "#ff0000";
}
})();
function dateToEpoch2(thedate) {
return thedate.setHours(0, 0, 0, 0);
}
function selectTheme() {
var select = document.getElementById("themes");
var value = select.options[select.selectedIndex].value;
chrome.storage.sync.set({ currentTheme: value }, function () {
console.log("Settings saved.");
});
chrome.tabs.query({
active: true,
lastFocusedWindow: true
}, function (tabs) {
var tab = tabs[0];
if (tab.url.includes("github.com")) {
chrome.tabs.reload();
}
});
}
function setCurrentTheme(currentTheme) {
const current = currentTheme.currentTheme;
var select = document.querySelector(`[value=${current}]`);
if (current != undefined) select.setAttribute("selected", "selected");
}
function chbg(color) {
document.getElementById("themes").style.border = color;
}
chrome.storage.sync.get(["currentTheme"], setCurrentTheme);