-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgm_darkmode.js
39 lines (35 loc) · 1.05 KB
/
gm_darkmode.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
// ==UserScript==
// @name Change dark mode
// @version 0.0.1
// @description Enables/disables dark mode
// @author Felipe
// @match *
// @grant GM.registerButton
// @grant GM.updateButton
// @grant GM.darkmode
// @grant GM.isDarkmodeEnabled
// @noframes
// ==/UserScript==
const id = 'change-darkmode';
const enableTitle = 'Enable Dark Mode';
const disableTitle = 'Disable Dark Mode';
const enableIcon = { name: 'sun', style: 'solid', font: 'font-awesome' };
const disableIcon = { name: 'moon', style: 'solid', font: 'font-awesome' };
const run = async () => {
let enabled = await GM.isDarkmodeEnabled();
GM.registerButton({
id,
icon: enabled ? enableIcon : disableIcon,
caption: enabled ? enableTitle : disableTitle,
callback: async () => {
enabled = !(await GM.isDarkmodeEnabled());
GM.darkmode(enabled);
GM.updateButton({
id,
icon: enabled ? enableIcon : disableIcon,
caption: enabled ? enableTitle : disableTitle,
});
},
});
};
run();