mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-03 01:29:39 +02:00
Merge branch 'master' of github.com:gorhill/uBlock
This commit is contained in:
commit
bb1e131ae7
@ -455,11 +455,9 @@ vAPI.tabs.getTabId = function(target) {
|
|||||||
if ( vAPI.fennec ) {
|
if ( vAPI.fennec ) {
|
||||||
if ( target.browser ) {
|
if ( target.browser ) {
|
||||||
// target is a tab
|
// target is a tab
|
||||||
return target.browser.loadContext.DOMWindowID;
|
target = target.browser;
|
||||||
}
|
}
|
||||||
return target.loadContext.DOMWindowID;
|
return target.loadContext.DOMWindowID;
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( target.linkedPanel ) {
|
if ( target.linkedPanel ) {
|
||||||
|
@ -120,21 +120,35 @@ 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('');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
// https://github.com/gorhill/uBlock/issues/464
|
// https://github.com/gorhill/uBlock/issues/464
|
||||||
if ( document instanceof HTMLDocument === false ) {
|
if ( document instanceof HTMLDocument === false ) {
|
||||||
//console.debug('contentscript-start.js > not a HTLMDocument');
|
//console.debug('contentscript-start.js > not a HTLMDocument');
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because in case
|
// Because in case
|
||||||
@ -52,7 +52,7 @@ if ( !vAPI ) {
|
|||||||
// The links look like this:
|
// The links look like this:
|
||||||
// abp:subscribe?location=https://easylist-downloads.adblockplus.org/easyprivacy.txt[...]
|
// abp:subscribe?location=https://easylist-downloads.adblockplus.org/easyprivacy.txt[...]
|
||||||
|
|
||||||
if ( document.querySelector('[href^="abp:subscribe?"]') === null ) {
|
if ( document.querySelector('a[href^="abp:"]') === null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +66,16 @@ var onAbpLinkClicked = function(ev) {
|
|||||||
if ( ev.button !== 0 ) {
|
if ( ev.button !== 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var receiver = ev.target;
|
var target = ev.target;
|
||||||
if ( receiver === null ) {
|
var limit = 3;
|
||||||
return;
|
var href = '';
|
||||||
|
do {
|
||||||
|
if ( target instanceof HTMLAnchorElement ) {
|
||||||
|
href = target.href;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ( receiver.tagName.toLowerCase() !== 'a' ) {
|
target = target.parentNode;
|
||||||
return;
|
} while ( target && --limit );
|
||||||
}
|
|
||||||
var href = receiver.getAttribute('href') || '';
|
|
||||||
if ( href === '' ) {
|
if ( href === '' ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user