File tree 6 files changed +231
-0
lines changed
6 files changed +231
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Dark Mode Toggle
2
+
3
+ A simple Firefox extension that creates a toolbar button to toggle dark mode on and off.
4
+
5
+ Icons modified from originals by ionicons (ionic.io/ionicons).
Original file line number Diff line number Diff line change
1
+ let isDark ;
2
+
3
+ function updateState ( ) {
4
+ isDark = browser . browserSettings . overrideContentColorScheme
5
+ . get ( { } )
6
+ . then ( ( res ) => {
7
+ isDark = res . value == 'dark' ;
8
+ browser . browserAction . setIcon ( {
9
+ path : isDark ? "icons/moon.svg" : "icons/sun.svg"
10
+ } ) ;
11
+ } ) ;
12
+ }
13
+
14
+ function toggleDarkMode ( ) {
15
+ browser . browserSettings . overrideContentColorScheme
16
+ . set ( { value : isDark ? 'light' : 'dark' } )
17
+ . then ( ( ) => { updateState ( ) ; } ) ;
18
+ }
19
+
20
+ browser . browserAction . onClicked . addListener ( toggleDarkMode ) ;
21
+
22
+ // update when the extension loads initially
23
+ updateState ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "manifest_version" : 2 ,
3
+ "name" : " Dark Mode Toggle" ,
4
+ "version" : " 1.0" ,
5
+ "description" : " Toolbar button to toggle dark mode" ,
6
+ "icons" : {
7
+ "48" : " icons/toggle.svg" ,
8
+ "96" : " icons/toggle.svg"
9
+ },
10
+ "browser_action" : {
11
+ "default_icon" : " icons/toggle.svg" ,
12
+ "default_title" : " Toggle dark mode"
13
+ },
14
+ "background" : {
15
+ "scripts" : [
16
+ " background.js"
17
+ ]
18
+ },
19
+ "permissions" : [
20
+ " browserSettings"
21
+ ]
22
+ }
You can’t perform that action at this time.
0 commit comments