File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 108
108
navigator . serviceWorker . register ( "scripts/serviceworker.js" ) ;
109
109
}
110
110
111
+ // Check theme to set status bar color
112
+ changeThemeColor ( "#ffffff" , "#000000" ) ;
113
+
111
114
// Check if location permission is given
112
115
navigator . permissions . query ( { name : "geolocation" } ) . then ( result => {
113
116
if ( result . state === "granted" ) {
Original file line number Diff line number Diff line change @@ -94,9 +94,10 @@ function parseMillisecondsIntoTripTime(milliseconds, showSeconds = true) {
94
94
return ( absoluteHours > 0 ? h + "h" : "" ) + m + "m" + ( showSeconds ? s + "s" : "" ) ;
95
95
}
96
96
97
-
98
- function changeThemeColor ( color ) {
99
- metaThemeColor = document . querySelector ( "meta[name=theme-color]" ) . setAttribute ( "content" , color ) ;
97
+ function changeThemeColor ( color , darkModeColor = null ) {
98
+ isDarkMode ( ) && darkModeColor
99
+ ? document . querySelector ( "meta[name=theme-color]" ) . setAttribute ( "content" , darkModeColor )
100
+ : document . querySelector ( "meta[name=theme-color]" ) . setAttribute ( "content" , color ) ;
100
101
}
101
102
102
103
function downloadObjectAsJson ( exportObj , exportName ) {
@@ -108,3 +109,7 @@ function downloadObjectAsJson(exportObj, exportName) {
108
109
downloadAnchorNode . click ( ) ;
109
110
downloadAnchorNode . remove ( ) ;
110
111
}
112
+
113
+ function isDarkMode ( ) {
114
+ return window . matchMedia && window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches ;
115
+ }
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ function hideUserSettings() {
220
220
userSettings . classList . add ( "smooth-slide-to-bottom" ) ;
221
221
setTimeout ( ( ) => userSettings . remove ( ) , 300 ) ; // remove element after animation end
222
222
}
223
- changeThemeColor ( "#ffffff" ) ; // Set status bar color in PWA
223
+ changeThemeColor ( "#ffffff" , "#000000" ) ; // Set status bar color in PWA
224
224
}
225
225
226
226
function openSetProxyPrompt ( ) {
@@ -414,7 +414,7 @@ function openStatisticsMenu() {
414
414
updateStatisticsChart ( ) ;
415
415
416
416
// Set status bar color in PWA
417
- changeThemeColor ( "#231f20" ) ;
417
+ changeThemeColor ( "#231f20" , "#1a1517" ) ;
418
418
}
419
419
420
420
function hideStatisticsMenu ( ) {
You can’t perform that action at this time.
0 commit comments