From 29dff80731d964c990a8e850939abf40ec2212f6 Mon Sep 17 00:00:00 2001 From: Alexey Nurgaliev Date: Mon, 5 Feb 2024 21:36:19 +0300 Subject: [PATCH] ability to disable localStorage (#764) --- data/emulator.js | 11 ++++++++--- data/loader.js | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/data/emulator.js b/data/emulator.js index 62722b0..4ea43a3 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -3744,7 +3744,7 @@ class EmulatorJS { }; } saveSettings() { - if (!window.localStorage || !this.settingsLoaded) return; + if (!window.localStorage || this.config.disableLocalStorage || !this.settingsLoaded) return; const coreSpecific = { controlSettings: this.controls, settings: this.settings, @@ -3758,7 +3758,12 @@ class EmulatorJS { localStorage.setItem("ejs-"+this.getCore()+"-settings", JSON.stringify(coreSpecific)); } loadRewindEnabled() { - if (!window.localStorage) return; + if (!window.localStorage || this.config.disableLocalStorage) { + if (this.config.defaultOptions && this.config.defaultOptions.rewindEnabled) { + return this.config.defaultOptions.rewindEnabled === 'enabled'; + } + return false; + } let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings"); try { coreSpecific = JSON.parse(coreSpecific); @@ -3772,7 +3777,7 @@ class EmulatorJS { } } loadSettings() { - if (!window.localStorage) return; + if (!window.localStorage || this.config.disableLocalStorage) return; this.settingsLoaded = true; let ejs_settings = localStorage.getItem("ejs-settings"); let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings"); diff --git a/data/loader.js b/data/loader.js index 0bb7200..e5ec4ae 100644 --- a/data/loader.js +++ b/data/loader.js @@ -110,6 +110,7 @@ config.screenRecording = window.EJS_screenRecording; config.externalFiles = window.EJS_externalFiles; config.disableDatabases = window.EJS_disableDatabases; + config.disableLocalStorage = window.EJS_disableLocalStorage; if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") { try {