diff --git a/src/components/Preferences.vue b/src/components/Preferences.vue index d3123820..3fdbc547 100644 --- a/src/components/Preferences.vue +++ b/src/components/Preferences.vue @@ -177,7 +177,7 @@ export default { { code: "ml", name: "Malayalam" }, { code: "nb_NO", name: "Norwegian Bokmål" }, { code: "tr", name: "Turkish" }, - { code: 'bn', name: 'Bengali' } + { code: "bn", name: "Bengali" }, ], enabledCodecs: ["av1", "vp9", "avc"], }; @@ -217,7 +217,7 @@ export default { }); }); - if (localStorage) { + if (this.testLocalStorage) { this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks"); this.sponsorBlock = this.getPreferenceBoolean("sponsorblock", true); @@ -270,7 +270,7 @@ export default { }, methods: { onChange() { - if (localStorage) { + if (this.testLocalStorage) { var shouldReload = false; if ( diff --git a/src/main.js b/src/main.js index 13775325..3c9c57a9 100644 --- a/src/main.js +++ b/src/main.js @@ -108,7 +108,7 @@ const mixin = { var value; if ( (value = new URLSearchParams(window.location.search).get(key)) !== null || - (localStorage && (value = localStorage.getItem(key)) !== null) + (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { switch (String(value).toLowerCase()) { case "true": @@ -125,7 +125,7 @@ const mixin = { var value; if ( (value = new URLSearchParams(window.location.search).get(key)) !== null || - (localStorage && (value = localStorage.getItem(key)) !== null) + (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { return value; } else return defaultVal; @@ -134,7 +134,7 @@ const mixin = { var value; if ( (value = new URLSearchParams(window.location.search).get(key)) !== null || - (localStorage && (value = localStorage.getItem(key)) !== null) + (this.testLocalStorage && (value = localStorage.getItem(key)) !== null) ) { return Number(value); } else return defaultVal; @@ -202,6 +202,14 @@ const mixin = { authenticated(_this) { return _this.getAuthToken() !== undefined; }, + testLocalStorage() { + try { + if (window.localStorage !== undefined) localStorage; + return true; + } catch { + return false; + } + }, }, };