From d3223766c850783baeb180d04f0e74f359b1ad92 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Tue, 10 Mar 2015 13:06:59 +0100 Subject: [PATCH] Firefox: abp:subscribe --- platform/firefox/frameModule.js | 41 ++++++++------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index cd513dc..9e1c444 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -55,11 +55,6 @@ const contentObserver = { cpMessageName: hostName + ':shouldLoad', ignoredPopups: new WeakMap(), uniqueSandboxId: 1, - subscriberTargets: { - 'adblockplus.org': true, - 'adblockplus.me': true, - 'fanboy.co.nz': true - }, get componentRegistrar() { return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); @@ -265,8 +260,8 @@ const contentObserver = { this.removeEventListener('mousedown', contObs.ignorePopup, true); }, - observe: function(subject) { - let win = subject.defaultView; + observe: function(doc) { + let win = doc.defaultView; if ( !win ) { return; @@ -294,33 +289,17 @@ const contentObserver = { lss(this.contentBaseURI + 'vapi-client.js', sandbox); lss(this.contentBaseURI + 'contentscript-start.js', sandbox); - let docReady = function(e) { - this.removeEventListener(e.type, docReady, true); - lss(contentObserver.contentBaseURI + 'contentscript-end.js', sandbox); - }; - - subject.addEventListener('DOMContentLoaded', docReady, true); + let docReady = (e) => { + let doc = e.target; + doc.removeEventListener(e.type, docReady, true); + lss(this.contentBaseURI + 'contentscript-end.js', sandbox); -/* Does not work, I do not know why - - let docIdle = function(e) { - this.removeEventListener(e.type, docIdle); - lss(this.contentBaseURI + 'subscriber.js', sandbox); + if ( doc.querySelector('a[href^="abp:"]') ) { + lss(this.contentBaseURI + 'subscriber.js', sandbox); + } }; - var target = loc.host; - 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); - } -*/ + doc.addEventListener('DOMContentLoaded', docReady, true); } };