mirror of https://github.com/gorhill/uBlock.git
This addresses Opera seemingly not supporting managed storage.
As reported in 43a5ed735b (all_commit_comments)
This commit is contained in:
parent
b5eeeee572
commit
26b70a1e64
|
@ -37,6 +37,7 @@ var chrome = self.chrome;
|
|||
var manifest = chrome.runtime.getManifest();
|
||||
|
||||
vAPI.chrome = true;
|
||||
vAPI.opera = /\bOPR\/[\d.]+\b/.test(self.navigator.appVersion);
|
||||
|
||||
var noopFunc = function(){};
|
||||
|
||||
|
@ -1011,13 +1012,30 @@ vAPI.punycodeURL = function(url) {
|
|||
// https://github.com/gorhill/uBlock/issues/531
|
||||
// Storage area dedicated to admin settings. Read-only.
|
||||
|
||||
// https://github.com/gorhill/uBlock/commit/43a5ed735b95a575a9339b6e71a1fcb27a99663b#commitcomment-13965030
|
||||
// Not all Chromium-based browsers support managed storage. Merely testing or
|
||||
// exception handling in this case does NOT work: I don't why. The 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.
|
||||
|
||||
vAPI.adminStorage = {
|
||||
getItem: function(key, callback) {
|
||||
getItem: (function() {
|
||||
if ( vAPI.opera ) {
|
||||
return function(key, callback) {
|
||||
callback();
|
||||
};
|
||||
}
|
||||
return function(key, callback) {
|
||||
try {
|
||||
chrome.storage.managed.get(key, function(store) {
|
||||
callback(store[key] || undefined);
|
||||
});
|
||||
} catch (ex) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
})()
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue