From 0c5a9bfba6b799d0973398c5b10666829b575e28 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 3 Nov 2015 07:44:18 -0500 Subject: [PATCH] this fixes #900 --- platform/chromium/vapi-background.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index d8ba0dbb5..09c867c05 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -1024,6 +1024,8 @@ vAPI.punycodeURL = function(url) { // extension on Opera ends up in a non-sensical state, whereas vAPI become // undefined out of nowhere. So only solution left is to test explicitly for // Opera. +// https://github.com/gorhill/uBlock/issues/900 +// Also, UC Browser: http://www.upsieutoc.com/image/WXuH vAPI.adminStorage = { getItem: (function() { @@ -1033,10 +1035,19 @@ vAPI.adminStorage = { }; } return function(key, callback) { + var onRead = function(store) { + var data; + if ( + !chrome.runtime.lastError && + typeof store === 'object' && + store !== null + ) { + data = store[key]; + } + callback(data); + }; try { - chrome.storage.managed.get(key, function(store) { - callback(store[key] || undefined); - }); + chrome.storage.managed.get(key, onRead); } catch (ex) { callback(); }