| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
| 4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 7 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
| 8 | 8 |
| 9 let {Prefs} = require("prefs"); | 9 let {Prefs} = require("prefs"); |
| 10 let {WindowObserver} = require("windowObserver"); | 10 let {WindowObserver} = require("windowObserver"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 let data = event.target.responseText.replace(/%%CLASS%%/g, elementMarkerClass)
; | 41 let data = event.target.responseText.replace(/%%CLASS%%/g, elementMarkerClass)
; |
| 42 let styleService = Cc["@mozilla.org/content/style-sheet-service;1"].getService
(Ci.nsIStyleSheetService); | 42 let styleService = Cc["@mozilla.org/content/style-sheet-service;1"].getService
(Ci.nsIStyleSheetService); |
| 43 let styleURI = Services.io.newURI("data:text/css," + encodeURIComponent(data),
null, null); | 43 let styleURI = Services.io.newURI("data:text/css," + encodeURIComponent(data),
null, null); |
| 44 styleService.loadAndRegisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET
); | 44 styleService.loadAndRegisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET
); |
| 45 onShutdown.add(() => styleService.unregisterSheet(styleURI, Ci.nsIStyleSheetSe
rvice.USER_SHEET)); | 45 onShutdown.add(() => styleService.unregisterSheet(styleURI, Ci.nsIStyleSheetSe
rvice.USER_SHEET)); |
| 46 }, false); | 46 }, false); |
| 47 request.send(null); | 47 request.send(null); |
| 48 | 48 |
| 49 // Load our developer tools actor | 49 // Load our process script |
| 50 let processScript = "chrome://elemhidehelper/content/processScript.js?" + elemen
tMarkerClass; | 50 let info = require("info"); |
| 51 let processScript = info.addonRoot + "lib/child/bootstrap.js?" + |
| 52 elementMarkerClass + "&" + |
| 53 "info=" + encodeURIComponent(JSON.stringify(info)); |
| 51 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] | 54 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
| 52 .getService(Ci.nsIProcessScriptLoader); | 55 .getService(Ci.nsIProcessScriptLoader); |
| 53 messageManager.loadProcessScript(processScript, true); | 56 messageManager.loadProcessScript(processScript, true); |
| 54 onShutdown.add(() => { | 57 onShutdown.add(() => { |
| 55 messageManager.removeDelayedProcessScript(processScript); | 58 messageManager.removeDelayedProcessScript(processScript); |
| 56 messageManager.QueryInterface(Ci.nsIMessageBroadcaster).broadcastAsyncMessage(
"ElemHideHelper:Shutdown"); | 59 messageManager.QueryInterface(Ci.nsIMessageBroadcaster) |
| 60 .broadcastAsyncMessage("ElemHideHelper:Shutdown"); |
| 57 }); | 61 }); |
| 58 | 62 |
| 59 // Load overlay asynchonously and start attaching to windows once done | 63 // Load overlay asynchonously and start attaching to windows once done |
| 60 request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIJSX
MLHttpRequest); | 64 request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIJSX
MLHttpRequest); |
| 61 request.open("GET", "chrome://elemhidehelper/content/overlay.xul"); | 65 request.open("GET", "chrome://elemhidehelper/content/overlay.xul"); |
| 62 request.channel.owner = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPr
incipal); | 66 request.channel.owner = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPr
incipal); |
| 63 request.addEventListener("load", function(event) | 67 request.addEventListener("load", function(event) |
| 64 { | 68 { |
| 65 if (onShutdown.done) | 69 if (onShutdown.done) |
| 66 return; | 70 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 96 if (element) | 100 if (element) |
| 97 element.parentNode.removeChild(element); | 101 element.parentNode.removeChild(element); |
| 98 | 102 |
| 99 for (let child = window.document.firstChild; child; child = child.nextSibl
ing) | 103 for (let child = window.document.firstChild; child; child = child.nextSibl
ing) |
| 100 if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.in
dexOf("elemhidehelper-node") >= 0) | 104 if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.in
dexOf("elemhidehelper-node") >= 0) |
| 101 child.parentNode.removeChild(child); | 105 child.parentNode.removeChild(child); |
| 102 } | 106 } |
| 103 }); | 107 }); |
| 104 }, false); | 108 }, false); |
| 105 request.send(null); | 109 request.send(null); |
| OLD | NEW |