-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtomorrow-theme.user.js
141 lines (136 loc) · 4.8 KB
/
tomorrow-theme.user.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
135
136
137
138
139
140
141
// ==UserScript==
// @name Tomorrow theme
// @description A simple userscript to use native site controls to automatically enable an appropriate native dark theme on various sites for cookie-disabled browsers.
// @author matoro <[email protected]>
// @namespace Violentmonkey Scripts
// @downloadURL https://raw.githubusercontent.com/matoro/tomorrow-theme/master/tomorrow-theme.user.js
// @license GPLv3 - https://www.gnu.org/licenses/gpl-3.0.txt
// @match *://8ch.net/*
// @match *://boards.4chan.org/*
// @match *://boards.4channel.org/*
// @match *://docs.microsoft.com/*
// @match *://duckduckgo.com/*
// @match *://en.wikipedia.org/*
// @match *://endchan.org/*
// @match *://gamefaqs.gamespot.com/*
// @match *://nyaa.si/*
// @match *://tvtropes.org/*
// @match *://videocardz.com/*
// @match *://wizchan.org/*
// @match *://youtu.be/*
// @match *://youtube.com/*
// @match *://www.youtube.com/*
// @grant none
// @version 0.1.012
// @updateURL https://raw.githubusercontent.com/matoro/tomorrow-theme/master/tomorrow-theme.user.js
// ==/UserScript==
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
window.addEventListener("load", function()
{
switch(window.location.hostname)
{
case "8ch.net":
var style = document.getElementById("stylechooser");
style.value = "Tomorrow";
style.dispatchEvent(new Event("change"));
break;
case "boards.4chan.org":
case "boards.4channel.org":
var style = document.getElementById("styleSelector");
if(style.value !== "Tomorrow")
{
style.value = "Tomorrow";
style.dispatchEvent(new Event("change"));
}
break;
case "docs.microsoft.com":
if(!document.documentElement.classList.contains("theme-dark"))
{
document.documentElement.classList.remove("theme-light");
document.documentElement.classList.add("theme-dark");
}
break;
case "duckduckgo.com":
DDG.settings.set("kae", "d");
break;
case "en.wikipedia.org":
waitForElm("#skin-client-pref-skin-theme-value-night").then((elm) => { elm.click(); });
break;
case "endchan.org":
chooseStyle("Darkend", "color");
break;
case "gamefaqs.gamespot.com":
var style = document.cookie.match(new RegExp("(^| )gf_css=([^;]+)"));
if(!style || style[2] !== "dark-blue")
{
document.querySelector("li.footer_color_subnav_item:nth-child(2) > a:nth-child(1)").click();
}
break;
case "nyaa.si":
if(!document.body.classList.contains("dark"))
{
document.getElementById("themeToggle").click();
}
break;
case "tvtropes.org":
var style = document.getElementById("sidebar-toggle-nightvision");
if(!Array.from(style.classList).includes("active"))
{
style.click();
}
break;
case "videocardz.com":
document.body.parentElement.setAttribute("data-theme", "dark");
break;
case "wizchan.org":
var style = document.getElementById("style-select");
style.childNodes.value = "10";
style.childNodes[1].dispatchEvent(new Event("change"));
break;
case "youtu.be":
case "youtube.com":
case "www.youtube.com":
for(var i = 0; i < 20; i++)
{
window.setTimeout(function() {
document.documentElement.setAttribute("dark", true);
document.documentElement.dispatchEvent(new Event("change"));
}, i * 250);
}
break;
default:
break;
}
}
);