diff --git a/platform/firefox/bootstrap.js b/platform/firefox/bootstrap.js deleted file mode 100644 index c11454041..000000000 --- a/platform/firefox/bootstrap.js +++ /dev/null @@ -1,250 +0,0 @@ -/******************************************************************************* - - uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2017 The uBlock Origin authors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - - Home: https://github.com/gorhill/uBlock -*/ - -/* global ADDON_UNINSTALL, APP_SHUTDOWN */ -/* exported startup, shutdown, install, uninstall */ - -'use strict'; - -/******************************************************************************/ - -const {classes: Cc, interfaces: Ci, utils: Cu} = Components; - -// Accessing the context of the background page: -// var win = Services.appShell.hiddenDOMWindow.document.querySelector('iframe[src*=ublock0]').contentWindow; - -let windowlessBrowser = null; -let windowlessBrowserPL = null; -let bgProcess = null; -let version; -const hostName = 'ublock0'; -const restartListener = { - get messageManager() { - return Cc['@mozilla.org/parentprocessmessagemanager;1'] - .getService(Ci.nsIMessageListenerManager); - }, - - receiveMessage: function() { - shutdown(); - startup(); - } -}; - -/******************************************************************************/ - -function startup(data/*, reason*/) { - if ( data !== undefined ) { - version = data.version; - } - - // Already started? - if ( bgProcess !== null ) { - return; - } - - waitForHiddenWindow(); -} - -function createBgProcess(parentDocument) { - bgProcess = parentDocument.documentElement.appendChild( - parentDocument.createElementNS('http://www.w3.org/1999/xhtml', 'iframe') - ); - bgProcess.setAttribute( - 'src', - 'chrome://' + hostName + '/content/background.html#' + version - ); - - // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIMessageListenerManager#addMessageListener%28%29 - // "If the same listener registers twice for the same message, the - // "second registration is ignored." - restartListener.messageManager.addMessageListener( - hostName + '-restart', - restartListener - ); -} - -function getWindowlessBrowserFrame(appShell) { - windowlessBrowser = appShell.createWindowlessBrowser(true); - windowlessBrowser.QueryInterface(Ci.nsIInterfaceRequestor); - let webProgress = windowlessBrowser.getInterface(Ci.nsIWebProgress); - let XPCOMUtils = Cu.import('resource://gre/modules/XPCOMUtils.jsm', null).XPCOMUtils; - windowlessBrowserPL = { - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIWebProgressListener, - Ci.nsIWebProgressListener2, - Ci.nsISupportsWeakReference - ]), - onStateChange: function(wbp, request, stateFlags/*, status*/) { - if ( !request ) { return; } - if ( stateFlags & Ci.nsIWebProgressListener.STATE_STOP ) { - webProgress.removeProgressListener(windowlessBrowserPL); - windowlessBrowserPL = null; - createBgProcess(windowlessBrowser.document); - } - } - }; - webProgress.addProgressListener(windowlessBrowserPL, Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT); - windowlessBrowser.document.location = "data:application/vnd.mozilla.xul+xml;charset=utf-8,"; -} - -function waitForHiddenWindow() { - let appShell = Cc['@mozilla.org/appshell/appShellService;1'] - .getService(Ci.nsIAppShellService); - - let isReady = function() { - var hiddenDoc; - - try { - hiddenDoc = appShell.hiddenDOMWindow && - appShell.hiddenDOMWindow.document; - } catch (ex) { - } - - // Do not test against `loading`: it does appear `readyState` could be - // undefined if looked up too early. - if ( !hiddenDoc || hiddenDoc.readyState !== 'complete' ) { - return false; - } - - // In theory, it should be possible to create a windowless browser - // immediately, without waiting for the hidden window to have loaded - // completely. However, in practice, on Windows this seems to lead - // to a broken Firefox appearance. To avoid this, we only create the - // windowless browser here. We'll use that rather than the hidden - // window for the actual background page (windowless browsers are - // also what the webextension implementation in Firefox uses for - // background pages). - let { Services } = Cu.import('resource://gre/modules/Services.jsm', null); - if ( Services.vc.compare(Services.appinfo.platformVersion, '27') >= 0 ) { - getWindowlessBrowserFrame(appShell); - } else { - createBgProcess(hiddenDoc); - } - return true; - }; - - if ( isReady() ) { - return; - } - - // https://github.com/gorhill/uBlock/issues/749 - // Poll until the proper environment is set up -- or give up eventually. - // We poll frequently early on but relax poll delay as time pass. - - let tryDelay = 5; - let trySum = 0; - // https://trac.torproject.org/projects/tor/ticket/19438 - // Try for a longer period. - let tryMax = 600011; - let timer = Cc['@mozilla.org/timer;1'] - .createInstance(Ci.nsITimer); - - let checkLater = function() { - trySum += tryDelay; - if ( trySum >= tryMax ) { - timer = null; - return; - } - timer.init(timerObserver, tryDelay, timer.TYPE_ONE_SHOT); - tryDelay *= 2; - if ( tryDelay > 503 ) { - tryDelay = 503; - } - }; - - var timerObserver = { - observe: function() { - timer.cancel(); - if ( isReady() ) { - timer = null; - } else { - checkLater(); - } - } - }; - - checkLater(); -} - -/******************************************************************************/ - -function shutdown(data, reason) { - if ( reason === APP_SHUTDOWN ) { - return; - } - - if ( bgProcess !== null ) { - bgProcess.parentNode.removeChild(bgProcess); - bgProcess = null; - } - - if ( windowlessBrowser !== null ) { - // close() does not exist for older versions of Firefox. - if ( typeof windowlessBrowser.close === 'function' ) { - windowlessBrowser.close(); - } - windowlessBrowser = null; - windowlessBrowserPL = null; - } - - if ( data === undefined ) { - return; - } - - // Remove the restartObserver only when the extension is being disabled - restartListener.messageManager.removeMessageListener( - hostName + '-restart', - restartListener - ); -} - -/******************************************************************************/ - -function install(/*aData, aReason*/) { - // https://bugzil.la/719376 - Cc['@mozilla.org/intl/stringbundle;1'] - .getService(Ci.nsIStringBundleService) - .flushBundles(); -} - -/******************************************************************************/ - -// https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions#uninstall -// "if you have code in uninstall it will not run, you MUST run some code -// "in the install function, at the least you must set arguments on the -// "install function so like: function install(aData, aReason) {} then -// "uninstall WILL WORK." - -function uninstall(aData, aReason) { - if ( aReason !== ADDON_UNINSTALL ) { - return; - } - // https://github.com/gorhill/uBlock/issues/84 - // "Add cleanup task to remove local storage settings when uninstalling" - // To cleanup vAPI.localStorage in vapi-common.js - // As I get more familiar with FF API, will find out whetehr there was - // a better way to do this. - Cu.import('resource://gre/modules/Services.jsm', null) - .Services.prefs.getBranch('extensions.' + hostName + '.') - .deleteBranch(''); -} - -/******************************************************************************/ diff --git a/platform/firefox/chrome.manifest b/platform/firefox/chrome.manifest deleted file mode 100644 index 75781cd6f..000000000 --- a/platform/firefox/chrome.manifest +++ /dev/null @@ -1 +0,0 @@ -content ublock0 ./ diff --git a/platform/firefox/css/legacy-toolbar-button.css b/platform/firefox/css/legacy-toolbar-button.css deleted file mode 100644 index c4e22522d..000000000 --- a/platform/firefox/css/legacy-toolbar-button.css +++ /dev/null @@ -1,46 +0,0 @@ -#uBlock0-legacy-button { - list-style-image: url('../img/browsericons/icon24.svg'); -} -#uBlock0-legacy-button.off { - list-style-image: url('../img/browsericons/icon24-off.svg'); -} - -toolbar[iconsize="small"] #uBlock0-legacy-button { - list-style-image: url('../img/browsericons/icon16.svg'); -} -toolbar[iconsize="small"] #uBlock0-legacy-button.off { - list-style-image: url('../img/browsericons/icon16-off.svg'); -} -#uBlock0-legacy-button[badge]::before { - background: #555; - color: #fff; - content: attr(badge); - font: bold 10px sans-serif; - margin-top: -2px; - padding: 0 2px; - position: fixed; -} -/* This hack required because if the before content changes it de-pops the - popup (without firing any events). So just hide it instead. Note, can't - actually *hide* it, or the same thing happens. -**/ -#uBlock0-legacy-button[badge=""]::before { - padding: 0; -} - -/* Override off state when in palette */ -toolbarpaletteitem #uBlock0-legacy-button.off { - list-style-image: url('../img/browsericons/icon24.svg'); -} - -/* Override badge when in palette */ -toolbarpaletteitem #uBlock0-legacy-button[badge]::before { - content: none; -} - -/* Prevent pale moon from showing the arrow underneath the button */ -/* https://github.com/chrisaljoudi/uBlock/issues/1449#issuecomment-112112761 */ -#uBlock0-legacy-button .toolbarbutton-menu-dropmarker { - display: none; - -moz-box-orient: horizontal; -} diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js deleted file mode 100644 index 03ef0bebd..000000000 --- a/platform/firefox/frameModule.js +++ /dev/null @@ -1,623 +0,0 @@ -/******************************************************************************* - - uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2017 The uBlock Origin authors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - - Home: https://github.com/gorhill/uBlock -*/ - -/* exported processObserver */ - -'use strict'; - -/******************************************************************************/ - -// https://github.com/gorhill/uBlock/issues/800 -this.EXPORTED_SYMBOLS = [ - 'contentObserver', - 'processObserver', - 'LocationChangeListener' -]; - -const {interfaces: Ci, utils: Cu} = Components; -const {Services} = Cu.import('resource://gre/modules/Services.jsm', null); -const {XPCOMUtils} = Cu.import('resource://gre/modules/XPCOMUtils.jsm', null); - -const hostName = Services.io.newURI(Components.stack.filename, null, null).host; -const rpcEmitterName = hostName + ':child-process-message'; - -//Cu.import('resource://gre/modules/Console.jsm'); // Firefox >= 44 -//Cu.import('resource://gre/modules/devtools/Console.jsm'); // Firefox < 44 - -/******************************************************************************/ - -const getMessageManager = function(win) { - let iface = win - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .sameTypeRootTreeItem - .QueryInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIInterfaceRequestor); - - try { - return iface.getInterface(Ci.nsIContentFrameMessageManager); - } catch (ex) { - // This can throw. It appears `shouldLoad` can be called *after* a - // tab has been closed. For example, a case where this happens all - // the time (FF38): - // - Open twitter.com (assuming you have an account and are logged in) - // - Close twitter.com - // There will be an exception raised when `shouldLoad` is called - // to process a XMLHttpRequest with URL `https://twitter.com/i/jot` - // fired from `https://twitter.com/`, *after* the tab is closed. - // In such case, `win` is `about:blank`. - } - return null; -}; - -/******************************************************************************/ - -// https://github.com/gorhill/uBlock/issues/2014 -// Have a dictionary of hostnames for which there are script tag filters. This -// allow for coarse-testing before firing a synchronous message to the -// parent process. Script tag filters are not very common, so this allows -// to skip the blocking of the child process most of the time. - -var scriptTagFilterer = (function() { - var scriptTagHostnames; - - var getCpmm = function() { - var svc = Services; - if ( !svc ) { return; } - var cpmm = svc.cpmm; - if ( cpmm ) { return cpmm; } - cpmm = Components.classes['@mozilla.org/childprocessmessagemanager;1']; - if ( cpmm ) { return cpmm.getService(Ci.nsISyncMessageSender); } - }; - - var getScriptTagHostnames = function() { - if ( scriptTagHostnames ) { - return scriptTagHostnames; - } - var cpmm = getCpmm(); - if ( !cpmm ) { return; } - var r = cpmm.sendSyncMessage(rpcEmitterName, { fnName: 'getScriptTagHostnames' }); - if ( Array.isArray(r) && Array.isArray(r[0]) ) { - scriptTagHostnames = new Set(r[0]); - } - return scriptTagHostnames; - }; - - var getScriptTagFilters = function(details) { - let cpmm = getCpmm(); - if ( !cpmm ) { return; } - let r = cpmm.sendSyncMessage(rpcEmitterName, { - fnName: 'getScriptTagFilters', - rootURL: details.rootURL, - frameURL: details.frameURL, - frameHostname: details.frameHostname - }); - if ( Array.isArray(r) ) { - return r[0]; - } - }; - - var regexFromHostname = function(details) { - // If target hostname has no script tag filter, no point querying - // chrome process. - var hostnames = getScriptTagHostnames(); - if ( !hostnames ) { return; } - var hn = details.frameHostname, pos, entity; - for (;;) { - if ( hostnames.has(hn) ) { - return getScriptTagFilters(details); - } - pos = hn.indexOf('.'); - if ( pos === -1 ) { break; } - entity = hn.slice(0, pos) + '.*'; - if ( hostnames.has(entity) ) { - return getScriptTagFilters(details); - } - hn = hn.slice(pos + 1); - if ( hn === '' ) { break; } - } - }; - - var reset = function() { - scriptTagHostnames = undefined; - }; - - return { - get: regexFromHostname, - reset: reset - }; -})(); - -/******************************************************************************/ - -var contentObserver = { - classDescription: 'content-policy for ' + hostName, - classID: Components.ID('{7afbd130-cbaf-46c2-b944-f5d24305f484}'), - contractID: '@' + hostName + '/content-policy;1', - ACCEPT: Ci.nsIContentPolicy.ACCEPT, - REJECT: Ci.nsIContentPolicy.REJECT_REQUEST, - MAIN_FRAME: Ci.nsIContentPolicy.TYPE_DOCUMENT, - SUB_FRAME: Ci.nsIContentPolicy.TYPE_SUBDOCUMENT, - contentBaseURI: 'chrome://' + hostName + '/content/js/', - cpMessageName: hostName + ':shouldLoad', - popupMessageName: hostName + ':shouldLoadPopup', - ignoredPopups: new WeakMap(), - uniquePopupEventId: 1, - uniqueSandboxId: 1, - modernFirefox: Services.vc.compare(Services.appinfo.platformVersion, '44') > 0, - - get componentRegistrar() { - return Components.manager.QueryInterface(Ci.nsIComponentRegistrar); - }, - - get categoryManager() { - return Components.classes['@mozilla.org/categorymanager;1'] - .getService(Ci.nsICategoryManager); - }, - - QueryInterface: XPCOMUtils.generateQI([ - Ci.nsIFactory, - Ci.nsIObserver, - Ci.nsIContentPolicy, - Ci.nsISupportsWeakReference - ]), - - createInstance: function(outer, iid) { - if ( outer ) { - throw Components.results.NS_ERROR_NO_AGGREGATION; - } - - return this.QueryInterface(iid); - }, - - register: function() { - Services.obs.addObserver(this, 'document-element-inserted', true); - Services.obs.addObserver(this, 'content-document-global-created', true); - - // https://bugzilla.mozilla.org/show_bug.cgi?id=1232354 - // For modern versions of Firefox, the frameId/parentFrameId - // information can be found in channel.loadInfo of the HTTP observer. - if ( this.modernFirefox !== true ) { - this.componentRegistrar.registerFactory( - this.classID, - this.classDescription, - this.contractID, - this - ); - this.categoryManager.addCategoryEntry( - 'content-policy', - this.contractID, - this.contractID, - false, - true - ); - } - }, - - unregister: function() { - Services.obs.removeObserver(this, 'document-element-inserted'); - Services.obs.removeObserver(this, 'content-document-global-created'); - - if ( this.modernFirefox !== true ) { - this.componentRegistrar.unregisterFactory(this.classID, this); - this.categoryManager.deleteCategoryEntry( - 'content-policy', - this.contractID, - false - ); - } - }, - - getFrameId: function(win) { - return win - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils) - .outerWindowID; - }, - - // https://bugzil.la/612921 - shouldLoad: function(type, location, origin, context) { - // For whatever reason, sometimes the global scope is completely - // uninitialized at this point. Repro steps: - // - Launch FF with uBlock enabled - // - Disable uBlock - // - Enable uBlock - // - Services and all other global variables are undefined - // Hopefully will eventually understand why this happens. - if ( Services === undefined || !context ) { - return this.ACCEPT; - } - - if ( !location.schemeIs('http') && !location.schemeIs('https') ) { - return this.ACCEPT; - } - - if ( type === this.MAIN_FRAME ) { - context = context.contentWindow || context; - } else if ( type === this.SUB_FRAME ) { - context = context.contentWindow; - } else { - context = (context.ownerDocument || context).defaultView; - } - - // https://github.com/gorhill/uBlock/issues/1893 - // I don't know why this happens. I observed that when it occurred, the - // resource was not seen by the HTTP observer, as if it was a spurious - // call to shouldLoad(). - if ( !context ) { - return this.ACCEPT; - } - - // The context for the toolbar popup is an iframe element here, - // so check context.top instead of context - if ( !context.top || !context.location ) { - return this.ACCEPT; - } - - let messageManager = getMessageManager(context); - if ( messageManager === null ) { - return this.ACCEPT; - } - - let isTopContext = context === context.top; - var parentFrameId; - if ( isTopContext ) { - parentFrameId = -1; - } else if ( context.parent === context.top ) { - parentFrameId = 0; - } else { - parentFrameId = this.getFrameId(context.parent); - } - - let rpcData = this.rpcData; - rpcData.frameId = isTopContext ? 0 : this.getFrameId(context); - rpcData.pFrameId = parentFrameId; - rpcData.type = type; - rpcData.url = location.spec; - - //console.log('shouldLoad: type=' + type + ' url=' + location.spec); - if ( typeof messageManager.sendRpcMessage === 'function' ) { - // https://bugzil.la/1092216 - messageManager.sendRpcMessage(this.cpMessageName, rpcData); - } else { - // Compatibility for older versions - messageManager.sendSyncMessage(this.cpMessageName, rpcData); - } - - return this.ACCEPT; - }, - - // Reuse object to avoid repeated memory allocation. - rpcData: { frameId: 0, pFrameId: -1, type: 0, url: '' }, - - initContentScripts: function(win, create) { - let messager = getMessageManager(win); - let sandboxId = hostName + ':sb:' + this.uniqueSandboxId++; - let sandbox; - - if ( create ) { - let sandboxName = [ - win.location.href.slice(0, 100), - win.document.title.slice(0, 100) - ].join(' | '); - - // https://github.com/gorhill/uMatrix/issues/325 - // "Pass sameZoneAs to sandbox constructor to make GCs cheaper" - sandbox = Cu.Sandbox([win], { - sameZoneAs: win.top, - sandboxName: sandboxId + '[' + sandboxName + ']', - sandboxPrototype: win, - wantComponents: false, - wantXHRConstructor: false - }); - - sandbox.getScriptTagFilters = function(details) { - return scriptTagFilterer.get(details); - }; - - sandbox.injectScript = function(script) { - let svc = Services; - // Sandbox appears void. - // I've seen this happens, need to investigate why. - if ( svc === undefined ) { return; } - svc.scriptloader.loadSubScript(script, sandbox); - }; - - let canUserStyles = (function() { - try { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils) - .loadSheetUsingURIString instanceof Function; - } catch(ex) { - } - return false; - })(); - - if ( canUserStyles ) { - sandbox.injectCSS = function(sheetURI) { - try { - let wu = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - wu.loadSheetUsingURIString(sheetURI, wu.USER_SHEET); - } catch(ex) { - } - }; - sandbox.removeCSS = function(sheetURI) { - try { - let wu = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils); - wu.removeSheetUsingURIString(sheetURI, wu.USER_SHEET); - } catch (ex) { - } - }; - } - - sandbox.topContentScript = win === win.top; - - // https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Message_Manager/Frame_script_loading_and_lifetime#Unloading_frame_scripts - // The goal is to have content scripts removed from web pages. This - // helps remove traces of uBlock from memory when disabling/removing - // the addon. - // For example, this takes care of: - // https://github.com/gorhill/uBlock/commit/ea4faff383789053f423498c1f1165c403fde7c7#commitcomment-11964137 - // > "gets the whole selected tab flashing" - sandbox.outerShutdown = function() { - sandbox.removeMessageListener(); - sandbox.addMessageListener = - sandbox.getScriptTagFilters = - sandbox.injectCSS = - sandbox.injectScript = - sandbox.outerShutdown = - sandbox.removeCSS = - sandbox.removeMessageListener = - sandbox.sendAsyncMessage = function(){}; - sandbox.vAPI = {}; - messager = null; - }; - } - else { - sandbox = win; - } - - sandbox._sandboxId_ = sandboxId; - sandbox.sendAsyncMessage = messager.sendAsyncMessage; - - sandbox.addMessageListener = function(callback) { - if ( sandbox._messageListener_ ) { - sandbox.removeMessageListener(); - } - - sandbox._messageListener_ = function(message) { - callback(message.data); - }; - - sandbox._broadcastListener_ = function(message) { - // https://github.com/gorhill/uBlock/issues/2014 - if ( sandbox.topContentScript ) { - let details; - try { details = JSON.parse(message.data); } catch (ex) {} - let msg = details && details.msg || {}; - if ( msg.what === 'staticFilteringDataChanged' ) { - if ( scriptTagFilterer ) { - scriptTagFilterer.reset(); - } - } - } - callback(message.data); - }; - - messager.addMessageListener( - sandbox._sandboxId_, - sandbox._messageListener_ - ); - messager.addMessageListener( - hostName + ':broadcast', - sandbox._broadcastListener_ - ); - }; - - sandbox.removeMessageListener = function() { - if ( !sandbox._messageListener_ ) { - return; - } - // It throws sometimes, mostly when the popup closes - try { - messager.removeMessageListener( - sandbox._sandboxId_, - sandbox._messageListener_ - ); - } catch (ex) { - } - try { - messager.removeMessageListener( - hostName + ':broadcast', - sandbox._broadcastListener_ - ); - } catch (ex) { - } - - sandbox._messageListener_ = sandbox._broadcastListener_ = null; - }; - - return sandbox; - }, - - injectOtherContentScripts: function(doc, sandbox) { - let docReady = (e) => { - let doc = e.target; - doc.removeEventListener(e.type, docReady, true); - if ( doc.querySelector('a[href^="abp:"],a[href^="https://subscribe.adblockplus.org/?"]') ) { - Services.scriptloader.loadSubScript(this.contentBaseURI + 'scriptlets/subscriber.js', sandbox); - } - }; - if ( doc.readyState === 'loading') { - doc.addEventListener('DOMContentLoaded', docReady, true); - } else { - docReady({ target: doc, type: 'DOMContentLoaded' }); - } - }, - - ignorePopup: function(e) { - if ( e.isTrusted === false ) { return; } - let contObs = contentObserver; - contObs.ignoredPopups.set(this, true); - this.removeEventListener('keydown', contObs.ignorePopup, true); - this.removeEventListener('mousedown', contObs.ignorePopup, true); - }, - - lookupPopupOpener: function(popup) { - for (;;) { - let opener = popup.opener; - if ( !opener ) { return; } - if ( opener.top ) { opener = opener.top; } - if ( opener === popup ) { return; } - if ( !opener.location ) { return; } - if ( this.reValidPopups.test(opener.location.protocol) ) { - return opener; - } - // https://github.com/uBlockOrigin/uAssets/issues/255 - // - Mind chained about:blank popups. - if ( opener.location.href !== 'about:blank' ) { return; } - popup = opener; - } - }, - - reValidPopups: /^(?:blob|data|https?|javascript):/, - reMustInjectScript: /^(?:file|https?):/, - - observe: function(subject, topic) { - // For whatever reason, sometimes the global scope is completely - // uninitialized at this point. Repro steps: - // - Launch FF with uBlock enabled - // - Disable uBlock - // - Enable uBlock - // - Services and all other global variables are undefined - // Hopefully will eventually understand why this happens. - if ( Services === undefined ) { return; } - - // https://github.com/gorhill/uBlock/issues/2290 - if ( topic === 'content-document-global-created' ) { - if ( subject !== subject.top || !subject.opener ) { return; } - if ( this.ignoredPopups.has(subject) ) { return; } - let opener = this.lookupPopupOpener(subject); - if ( !opener ) { return; } - subject.addEventListener('keydown', this.ignorePopup, true); - subject.addEventListener('mousedown', this.ignorePopup, true); - let popupMessager = getMessageManager(subject); - if ( !popupMessager ) { return; } - let openerMessager = getMessageManager(opener); - if ( !openerMessager ) { return; } - popupMessager.sendAsyncMessage(this.popupMessageName, { - id: this.uniquePopupEventId, - popup: true - }); - openerMessager.sendAsyncMessage(this.popupMessageName, { - id: this.uniquePopupEventId, - opener: true - }); - this.uniquePopupEventId += 1; - return; - } - - // topic === 'document-element-inserted' - - let doc = subject; - let win = doc.defaultView || null; - if ( win === null ) { return; } - - // https://github.com/gorhill/uBlock/issues/260 - // https://developer.mozilla.org/en-US/docs/Web/API/Document/contentType - // "Non-standard, only supported by Gecko. To be used in - // "chrome code (i.e. Extensions and XUL applications)." - // TODO: We may have to exclude more types, for now let's be - // conservative and focus only on the one issue reported, i.e. let's - // not test against 'text/html'. - if ( doc.contentType.startsWith('image/') ) { return; } - - let loc = win.location; - if ( this.reMustInjectScript.test(loc.protocol) === false ) { - if ( loc.protocol === 'chrome:' && loc.host === hostName ) { - this.initContentScripts(win); - } - // What about data: and about:blank? - return; - } - - // Content scripts injection. - let lss = Services.scriptloader.loadSubScript; - let sandbox = this.initContentScripts(win, true); - try { - lss(this.contentBaseURI + 'vapi-client.js', sandbox); - lss(this.contentBaseURI + 'contentscript.js', sandbox); - } catch (ex) { - //console.exception(ex.msg, ex.stack); - return; - } - // The remaining scripts are worth injecting only on a top-level window - // and at document_idle time. - if ( win === win.top ) { - this.injectOtherContentScripts(doc, sandbox); - } - } -}; - -/******************************************************************************/ - -var processObserver = { - start: function() { - scriptTagFilterer.reset(); - } -}; - -/******************************************************************************/ - -var LocationChangeListener = function(docShell, webProgress) { - var mm = docShell.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIContentFrameMessageManager); - if ( !mm || typeof mm.sendAsyncMessage !== 'function' ) { - return; - } - this.messageManager = mm; - webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION); -}; - -LocationChangeListener.prototype.messageName = hostName + ':locationChanged'; - -LocationChangeListener.prototype.QueryInterface = XPCOMUtils.generateQI([ - 'nsIWebProgressListener', - 'nsISupportsWeakReference' -]); - -LocationChangeListener.prototype.onLocationChange = function(webProgress, request, location, flags) { - if ( !webProgress.isTopLevel ) { - return; - } - this.messageManager.sendAsyncMessage(this.messageName, { - url: location.asciiSpec, - flags: flags - }); -}; - -/******************************************************************************/ - -contentObserver.register(); - -/******************************************************************************/ diff --git a/platform/firefox/frameScript.js b/platform/firefox/frameScript.js deleted file mode 100644 index 260f05557..000000000 --- a/platform/firefox/frameScript.js +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - - uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2016 The uBlock Origin authors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - - Home: https://github.com/gorhill/uBlock -*/ - -/******************************************************************************/ - -// https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment - -(function(context) { - 'use strict'; - - if ( !context.docShell ) { - return; - } - - let webProgress = context.docShell - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIWebProgress); - if ( !webProgress ) { - return; - } - - // https://github.com/gorhill/uBlock/issues/1514 - // Fix? - let domWindow = webProgress.DOMWindow; - if ( domWindow !== domWindow.top ) { - return; - } - - let {LocationChangeListener} = Components.utils.import( - Components.stack.filename.replace('Script', 'Module'), - null - ); - - // https://github.com/gorhill/uBlock/issues/1444 - // Apparently, on older versions of Firefox (31 and less), the same context - // is used for all frame scripts, hence we must use a unique variable name - // to ensure no collision. - context.ublock0LocationChangeListener = new LocationChangeListener( - context.docShell, - webProgress - ); -})(this); - -/******************************************************************************/ diff --git a/platform/firefox/frameScript0.js b/platform/firefox/frameScript0.js deleted file mode 100644 index 38acce2ec..000000000 --- a/platform/firefox/frameScript0.js +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - - uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2016 The uBlock Origin authors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - - Home: https://github.com/gorhill/uBlock -*/ - -/******************************************************************************/ - -// https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment - -(function(context) { - - 'use strict'; - - if ( !context.content ) { - return; - } - - let {contentObserver} = Components.utils.import( - Components.stack.filename.replace('Script0', 'Module'), - null - ); - - let injectContentScripts = function(win) { - if ( !win || !win.document ) { - return; - } - - contentObserver.observe(win.document); - - if ( win.frames && win.frames.length ) { - let i = win.frames.length; - while ( i-- ) { - injectContentScripts(win.frames[i]); - } - } - }; - - injectContentScripts(context.content); - -})(this); - -/******************************************************************************/ diff --git a/platform/firefox/img/browsericons/icon16-off.svg b/platform/firefox/img/browsericons/icon16-off.svg deleted file mode 100644 index f0f68be23..000000000 --- a/platform/firefox/img/browsericons/icon16-off.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/platform/firefox/img/browsericons/icon16.svg b/platform/firefox/img/browsericons/icon16.svg deleted file mode 100644 index d36d9d232..000000000 --- a/platform/firefox/img/browsericons/icon16.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/platform/firefox/img/browsericons/icon24-off.svg b/platform/firefox/img/browsericons/icon24-off.svg deleted file mode 100644 index 0856eef34..000000000 --- a/platform/firefox/img/browsericons/icon24-off.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/platform/firefox/img/browsericons/icon24.svg b/platform/firefox/img/browsericons/icon24.svg deleted file mode 100644 index 28f75a726..000000000 --- a/platform/firefox/img/browsericons/icon24.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/platform/firefox/install.rdf b/platform/firefox/install.rdf deleted file mode 100644 index e9b39263a..000000000 --- a/platform/firefox/install.rdf +++ /dev/null @@ -1,64 +0,0 @@ - - - - uBlock0@raymondhill.net - {version} - {name} - {description} - {homepage} - {author} - Deathamns - Alex Vallat - Manuel Reimer - 2 - true - true - 2 -{localized} - - - - - {{ec8030f7-c20a-464f-9b0e-13a3a9e97384}} - 32.0 - 56.0a1 - - - - - - - {{aa3c5121-dab2-40e2-81ca-7ea25febc110}} - 32.0 - 56.0a1 - - - - - - - {{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}} - 2.24 - * - - - - - - - {{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}} - 27.0 - 27.* - - - - - - - {{3550f703-e582-4d05-9a08-453d09bdfdc6}} - 31.0 - 45.* - - - - diff --git a/platform/firefox/options.xul b/platform/firefox/options.xul deleted file mode 100644 index aee6f7c00..000000000 --- a/platform/firefox/options.xul +++ /dev/null @@ -1,9 +0,0 @@ - - - - -