mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-03 01:29:39 +02:00
Firefox: different kind of vAPI.localStorage
This commit is contained in:
parent
32837deba6
commit
5ae7687e56
@ -120,21 +120,34 @@ vAPI.closePopup = function() {
|
|||||||
// This storage is optional, but it is nice to have, for a more polished user
|
// This storage is optional, but it is nice to have, for a more polished user
|
||||||
// experience.
|
// experience.
|
||||||
|
|
||||||
Object.defineProperty(vAPI, 'localStorage', {
|
vAPI.localStorage = {
|
||||||
get: function() {
|
PB: Services.prefs.getBranch('extensions.' + location.host + '.'),
|
||||||
if ( this._localStorage ) {
|
str: Components.classes['@mozilla.org/supports-string;1']
|
||||||
return this._localStorage;
|
.createInstance(Components.interfaces.nsISupportsString),
|
||||||
|
getItem: function(key) {
|
||||||
|
try {
|
||||||
|
return this.PB.getComplexValue(
|
||||||
|
key, Components.interfaces.nsISupportsString
|
||||||
|
).data;
|
||||||
|
} catch (ex) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
this._localStorage = Services.domStorageManager.getLocalStorageForPrincipal(
|
setItem: function(key, value) {
|
||||||
Services.scriptSecurityManager.getCodebasePrincipal(
|
this.str.data = value;
|
||||||
Services.io.newURI('http://ublock.raymondhill.net/', null, null)
|
this.PB.setComplexValue(
|
||||||
),
|
key,
|
||||||
''
|
Components.interfaces.nsISupportsString,
|
||||||
|
this.str
|
||||||
);
|
);
|
||||||
return this._localStorage;
|
},
|
||||||
|
removeItem: function(key) {
|
||||||
|
this.PB.clearUserPref(key);
|
||||||
|
},
|
||||||
|
clear: function() {
|
||||||
|
this.PB.deleteBranch('');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user