/usr/share/xul-ext/adblock-plus-element-hiding-helper/main.js is in xul-ext-adblock-plus-element-hiding-helper 1.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /*
* This Source Code is subject to the terms of the Mozilla Public License
* version 2.0 (the "License"). You can obtain a copy of the License at
* http://mozilla.org/MPL/2.0/.
*/
Cu.import("resource://gre/modules/Services.jsm");
let {Prefs} = require("prefs");
let {WindowObserver} = require("windowObserver");
let {WindowWrapper} = require("windowWrapper");
// Check whether some preferences can still be found under their old locations
Prefs.migrate("extensions.adblockplus.ehh-selectelement_key", "selectelement_key");
Prefs.migrate("extensions.adblockplus.ehh.showhelp", "showhelp");
// Window types to attach to
let knownWindowTypes =
{
"navigator:browser": true,
"mail:3pane": true,
"mail:messageWindow": true,
__proto__: null
};
// Use random marker class
let elementMarkerClass = null;
{
let rnd = [];
let offset = "a".charCodeAt(0);
for (let i = 0; i < 20; i++)
rnd.push(offset + Math.random() * 26);
elementMarkerClass = String.fromCharCode.apply(String, rnd);
}
// Load CSS asynchronously
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
request.open("GET", "chrome://elemhidehelper/content/elementmarker.css");
request.overrideMimeType("text/plain");
request.addEventListener("load", function(event)
{
if (onShutdown.done)
return;
let data = event.target.responseText.replace(/%%CLASS%%/g, elementMarkerClass);
let styleService = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
let styleURI = Services.io.newURI("data:text/css," + encodeURIComponent(data), null, null);
styleService.loadAndRegisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET);
onShutdown.add(function() styleService.unregisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET));
}, false);
request.send(null);
// Load overlay asynchonously and start attaching to windows once done
request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIJSXMLHttpRequest);
request.open("GET", "chrome://elemhidehelper/content/overlay.xul");
request.addEventListener("load", function(event)
{
if (onShutdown.done)
return;
let overlay = event.target.responseXML.documentElement;
// Initialization done, we can start up now
require("inspectorObserver");
new WindowObserver({
applyToWindow: function(window)
{
let type = window.document.documentElement.getAttribute("windowtype");
if (!(type in knownWindowTypes) || window._ehhWrapper)
return;
window.document.documentElement.appendChild(overlay.cloneNode(true));
let style = window.document.createProcessingInstruction("xml-stylesheet", 'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" type="text/css"');
window.document.insertBefore(style, window.document.firstChild);
window._ehhWrapper = new WindowWrapper(window, elementMarkerClass);
},
removeFromWindow: function(window)
{
if (!window._ehhWrapper)
return;
window._ehhWrapper.shutdown();
delete window._ehhWrapper;
let element = window.document.getElementById(overlay.getAttribute("id"));
if (element)
element.parentNode.removeChild(element);
for (let child = window.document.firstChild; child; child = child.nextSibling)
if (child.nodeType == child.PROCESSING_INSTRUCTION_NODE && child.data.indexOf("elemhidehelper-node") >= 0)
child.parentNode.removeChild(child);
}
});
}, false);
request.send(null);
|