diff options
author | hackademix | 2019-12-29 01:07:10 +0100 |
---|---|---|
committer | hackademix | 2019-12-29 01:07:10 +0100 |
commit | cf5a0b05c09ad7b23265a96a944c82de71dfa3fc (patch) | |
tree | 504aab05d8197e78f0a1e3baa1d5f1d2c56a49bc /src/lib/SyncMessage.js | |
parent | 3a76c012df76614cb1de25c42ac7cbfc6a2bff27 (diff) | |
download | noscript-cf5a0b05c09ad7b23265a96a944c82de71dfa3fc.tar.gz noscript-cf5a0b05c09ad7b23265a96a944c82de71dfa3fc.tar.xz noscript-cf5a0b05c09ad7b23265a96a944c82de71dfa3fc.zip |
Fixed UI not working on pages were sessionStorage is disabled.
Diffstat (limited to 'src/lib/SyncMessage.js')
-rw-r--r-- | src/lib/SyncMessage.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index c889b2c..698822c 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -253,10 +253,16 @@ let r = new XMLHttpRequest(); let result; let key = `${ENDPOINT_PREFIX}`; - let reloaded = sessionStorage.getItem(key) === "reloaded"; - if (reloaded) { - sessionStorage.removeItem(key); - console.log("Syncmessage attempt aftert reloading page."); + let reloaded; + try { + reloaded = sessionStorage.getItem(key) === "reloaded"; + if (reloaded) { + sessionStorage.removeItem(key); + console.log("Syncmessage attempt aftert reloading page."); + } + } catch (e) { + // we can't access sessionStorage: let's act as we've already reloaded + reloaded = true; } for (let attempts = 3; attempts-- > 0;) { try { @@ -268,7 +274,7 @@ console.error(`syncMessage error in ${document.URL}: ${e.message} (response ${r.responseText}, remaining attempts ${attempts})`); if (attempts === 0) { if (reloaded) { - console.log("Already reloaded, giving up.") + console.log("Already reloaded or no sessionStorage, giving up.") break; } sessionStorage.setItem(key, "reloaded"); |