diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 828d698..77d9423 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -2493,13 +2493,13 @@ class Localuser { const sw = update.addSelect( I18n.localuser.swSettings(), () => {}, - (["SWOff", "SWOffline", "SWOn"] as const).map((e) => I18n.localuser[e]()), + (["SWOff", "SWOffline", "SWOn", "SWUnregistered"] as const).map((e) => I18n.localuser[e]()), { defaultIndex: index, }, ); sw.onchange = (e) => { - SW.setMode((["false", "offlineOnly", "true"] as const)[e]); + SW.setMode((["false", "offlineOnly", "true", "unregistered"] as const)[e]); }; update.addButtonInput("", I18n.localuser.CheckUpdate(), async () => { const update = await SW.checkUpdates(); diff --git a/src/webpage/utils/utils.ts b/src/webpage/utils/utils.ts index 595fbe1..550d058 100644 --- a/src/webpage/utils/utils.ts +++ b/src/webpage/utils/utils.ts @@ -986,6 +986,9 @@ export class SW { } static async start() { if (!("serviceWorker" in navigator)) return; + + // If it's registered, it handles CDN caching regardless of settings. + if(localStorage.getItem("SWMode") === "unregistered") return; return new Promise((res) => { navigator.serviceWorker .register("/service.js", { @@ -1016,7 +1019,7 @@ export class SW { }); }); } - static setMode(mode: "false" | "offlineOnly" | "true") { + static setMode(mode: "false" | "offlineOnly" | "true" | "unregistered") { localStorage.setItem("SWMode", mode); if (this.worker) { this.worker.postMessage({data: mode, code: "setMode"}); diff --git a/translations/en.json b/translations/en.json index 1fc7785..406185d 100644 --- a/translations/en.json +++ b/translations/en.json @@ -516,6 +516,7 @@ "VoiceWarning": "Are you sure you want to enable this? It's very experimental and is likely to cause issues. (this feature is for devs, please don't enable if you don't know what you're doing)", "updateSettings": "Update Settings", "swSettings": "Service Worker setting", + "SWUnregistered": "Off (including media cache)", "SWOff": "Off", "SWOffline": "Offline only", "SWOn": "On",