LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 23 matching lines...) Expand all Loading... |
34 let message = {payload, frames: getFrames(senderWindow)}; | 34 let message = {payload, frames: getFrames(senderWindow)}; |
35 if (typeof callback == "function") | 35 if (typeof callback == "function") |
36 port.emitWithResponse("ext_message", message).then(callback); | 36 port.emitWithResponse("ext_message", message).then(callback); |
37 else | 37 else |
38 port.emit("ext_message", message); | 38 port.emit("ext_message", message); |
39 } | 39 } |
40 } | 40 } |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
44 function loadScript(script) | |
45 { | |
46 Services.scriptloader.loadSubScript(script, scope); | |
47 } | |
48 | |
49 function addUserCSS(window, cssCode) | 44 function addUserCSS(window, cssCode) |
50 { | 45 { |
51 let uri = Services.io.newURI("data:text/css," + encodeURIComponent(cssCode), | 46 let uri = Services.io.newURI("data:text/css," + encodeURIComponent(cssCode), |
52 null, null); | 47 null, null); |
53 let utils = window.QueryInterface(Ci.nsIInterfaceRequestor) | 48 let utils = window.QueryInterface(Ci.nsIInterfaceRequestor) |
54 .getInterface(Ci.nsIDOMWindowUtils); | 49 .getInterface(Ci.nsIDOMWindowUtils); |
55 utils.loadSheet(uri, Ci.nsIDOMWindowUtils.USER_SHEET); | 50 utils.loadSheet(uri, Ci.nsIDOMWindowUtils.USER_SHEET); |
56 } | 51 } |
57 | 52 |
58 function initCSSPropertyFilters() | 53 function initCSSPropertyFilters() |
59 { | 54 { |
60 loadScript("chrome://adblockplus/content/cssProperties.js"); | 55 Services.scriptloader.loadSubScript( |
| 56 "chrome://adblockplus/content/cssProperties.js", scope); |
61 | 57 |
62 let onContentWindow = (subject, topic, data) => | 58 let onContentWindow = (subject, topic, data) => |
63 { | 59 { |
64 if (!(subject instanceof Ci.nsIDOMWindow)) | 60 if (!(subject instanceof Ci.nsIDOMWindow)) |
65 return; | 61 return; |
66 | 62 |
67 let onReady = event => | 63 let onReady = event => |
68 { | 64 { |
69 subject.removeEventListener("DOMContentLoaded", onReady); | 65 subject.removeEventListener("DOMContentLoaded", onReady); |
70 let handler = new scope.CSSPropertyFilters(subject, selectors => | 66 let handler = new scope.CSSPropertyFilters(subject, selectors => |
(...skipping 21 matching lines...) Expand all Loading... |
92 false); | 88 false); |
93 onShutdown.add(() => | 89 onShutdown.add(() => |
94 { | 90 { |
95 Services.obs.removeObserver(onContentWindow, | 91 Services.obs.removeObserver(onContentWindow, |
96 "content-document-global-created"); | 92 "content-document-global-created"); |
97 }); | 93 }); |
98 } | 94 } |
99 | 95 |
100 initCSSPropertyFilters(); | 96 initCSSPropertyFilters(); |
101 })(); | 97 })(); |
LEFT | RIGHT |