Work around localStorage not available in private windows. Fix #1163.

This commit is contained in:
FelisCatus 2017-10-12 21:51:19 -07:00
parent 52fdd252d2
commit 8572ff6b42
2 changed files with 10 additions and 2 deletions

View File

@ -311,8 +311,12 @@ refreshActivePageIfEnabled = ->
chrome.runtime.onMessage.addListener (request, sender, respond) ->
return unless request and request.method
options.ready.then ->
target = options
method = target[request.method]
if request.method == 'getState'
target = state
method = state.get
else
target = options
method = target[request.method]
if typeof method != 'function'
Log.error("No such method #{request.method}!")
respond(

View File

@ -24,6 +24,10 @@ var requestInfoCallback = null;
OmegaTargetPopup = {
getState: function (keys, cb) {
if (typeof localStorage === 'undefined' || !localStorage.length) {
callBackground('getState', [keys], cb);
return;
}
var results = {};
keys.forEach(function(key) {
try {