mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 17:19:38 +02:00
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();
|
var manifest = chrome.runtime.getManifest();
|
||||||
|
|
||||||
vAPI.chrome = true;
|
vAPI.chrome = true;
|
||||||
|
vAPI.opera = /\bOPR\/[\d.]+\b/.test(self.navigator.appVersion);
|
||||||
|
|
||||||
var noopFunc = function(){};
|
var noopFunc = function(){};
|
||||||
|
|
||||||
@ -1011,12 +1012,29 @@ vAPI.punycodeURL = function(url) {
|
|||||||
// https://github.com/gorhill/uBlock/issues/531
|
// https://github.com/gorhill/uBlock/issues/531
|
||||||
// Storage area dedicated to admin settings. Read-only.
|
// 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 = {
|
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) {
|
chrome.storage.managed.get(key, function(store) {
|
||||||
callback(store[key] || undefined);
|
callback(store[key] || undefined);
|
||||||
});
|
});
|
||||||
|
} catch (ex) {
|
||||||
|
callback();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
})()
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user