Skip to content

Commit 1a5c43e

Browse files
committed
fix: update status bar color
1 parent b2c3e48 commit 1a5c43e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
navigator.serviceWorker.register("scripts/serviceworker.js");
109109
}
110110

111+
// Check theme to set status bar color
112+
changeThemeColor("#ffffff", "#000000");
113+
111114
// Check if location permission is given
112115
navigator.permissions.query({ name: "geolocation" }).then(result => {
113116
if (result.state === "granted") {

scripts/extras.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ function parseMillisecondsIntoTripTime(milliseconds, showSeconds = true) {
9494
return (absoluteHours > 0 ? h + "h" : "") + m + "m" + (showSeconds ? s + "s" : "");
9595
}
9696

97-
function changeThemeColor(color) {
98-
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);
99101
}
100102

101103
function downloadObjectAsJson(exportObj, exportName) {
@@ -108,6 +110,10 @@ function downloadObjectAsJson(exportObj, exportName) {
108110
downloadAnchorNode.remove();
109111
}
110112

113+
function isDarkMode() {
114+
return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
115+
}
116+
111117
function getTLD() {
112118
let hostname = window.location.hostname;
113119

scripts/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ function hideUserSettings() {
282282
userSettings.classList.add("smooth-slide-to-bottom");
283283
setTimeout(() => userSettings.remove(), 300); // remove element after animation end
284284
}
285-
changeThemeColor("#ffffff"); // Set status bar color in PWA
285+
changeThemeColor("#ffffff", "#000000"); // Set status bar color in PWA
286286
}
287287

288288
function openSetProxyPrompt() {
@@ -480,7 +480,7 @@ function openStatisticsMenu() {
480480
updateStatisticsChart();
481481

482482
// Set status bar color in PWA
483-
changeThemeColor("#231f20");
483+
changeThemeColor("#231f20", "#1a1517");
484484
}
485485

486486
function hideStatisticsMenu() {

0 commit comments

Comments
 (0)