Firefox: abp:subscribe

This commit is contained in:
Deathamns 2015-03-10 13:06:59 +01:00
parent a795d6e073
commit c4b06eecd2
2 changed files with 12 additions and 33 deletions

View File

@ -55,11 +55,6 @@ const contentObserver = {
cpMessageName: hostName + ':shouldLoad', cpMessageName: hostName + ':shouldLoad',
ignoredPopups: new WeakMap(), ignoredPopups: new WeakMap(),
uniqueSandboxId: 1, uniqueSandboxId: 1,
subscriberTargets: {
'adblockplus.org': true,
'adblockplus.me': true,
'fanboy.co.nz': true
},
get componentRegistrar() { get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -265,8 +260,8 @@ const contentObserver = {
this.removeEventListener('mousedown', contObs.ignorePopup, true); this.removeEventListener('mousedown', contObs.ignorePopup, true);
}, },
observe: function(subject) { observe: function(doc) {
let win = subject.defaultView; let win = doc.defaultView;
if ( !win ) { if ( !win ) {
return; return;
@ -294,33 +289,17 @@ const contentObserver = {
lss(this.contentBaseURI + 'vapi-client.js', sandbox); lss(this.contentBaseURI + 'vapi-client.js', sandbox);
lss(this.contentBaseURI + 'contentscript-start.js', sandbox); lss(this.contentBaseURI + 'contentscript-start.js', sandbox);
let docReady = function(e) { let docReady = (e) => {
this.removeEventListener(e.type, docReady, true); let doc = e.target;
lss(contentObserver.contentBaseURI + 'contentscript-end.js', sandbox); doc.removeEventListener(e.type, docReady, true);
}; lss(this.contentBaseURI + 'contentscript-end.js', sandbox);
subject.addEventListener('DOMContentLoaded', docReady, true); if ( doc.querySelector('a[href^="abp:"]') ) {
/* Does not work, I do not know why
let docIdle = function(e) {
this.removeEventListener(e.type, docIdle);
lss(this.contentBaseURI + 'subscriber.js', sandbox); lss(this.contentBaseURI + 'subscriber.js', sandbox);
}
}; };
var target = loc.host; doc.addEventListener('DOMContentLoaded', docReady, true);
while ( target !== '' ) {
if ( this.subscriberTargets.hasOwnProperty(target) ) {
subject.addEventListener('load', docIdle);
break;
}
let pos = target.indexOf('.');
if ( pos === -1 ) {
break;
}
target = target.slice(pos + 1);
}
*/
} }
}; };

View File

@ -74,7 +74,7 @@ var onAbpLinkClicked = function(ev) {
if ( href === '' ) { if ( href === '' ) {
return; return;
} }
var matches = /^abp:subscribe\?location=([^&]+).*title=([^&]+)/.exec(href); var matches = /^abp:\/*subscribe\/*\?location=([^&]+).*title=([^&]+)/.exec(href);
if ( matches === null ) { if ( matches === null ) {
return; return;
} }