Left: | ||
Right: |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 14 matching lines...) Expand all Loading... | |
25 const {checkWhitelisted} = require("whitelisting"); | 25 const {checkWhitelisted} = require("whitelisting"); |
26 const {extractHostFromFrame} = require("url"); | 26 const {extractHostFromFrame} = require("url"); |
27 const {port} = require("messaging"); | 27 const {port} = require("messaging"); |
28 const devtools = require("devtools"); | 28 const devtools = require("devtools"); |
29 const info = require("info"); | 29 const info = require("info"); |
30 | 30 |
31 // Chromium's support for tabs.removeCSS is still a work in progress and the | 31 // Chromium's support for tabs.removeCSS is still a work in progress and the |
32 // API is likely to be different from Firefox's; for now we just don't use it | 32 // API is likely to be different from Firefox's; for now we just don't use it |
33 // at all, even if it's available. | 33 // at all, even if it's available. |
34 // See https://crbug.com/608854 | 34 // See https://crbug.com/608854 |
35 const styleSheetRemovalSupported = "removeCSS" in browser.tabs && | 35 const styleSheetRemovalSupported = info.platform == "gecko"; |
36 info.platform == "gecko"; | |
Sebastian Noack
2018/01/31 14:30:05
tabs.removeCSS() was added in Firefox 49. The olde
Manish Jethani
2018/02/01 08:05:07
Done.
| |
37 | 36 |
38 const selectorGroupSize = 1024; | 37 const selectorGroupSize = 1024; |
39 | 38 |
40 let userStyleSheetsSupported = true; | 39 let userStyleSheetsSupported = true; |
41 | 40 |
42 function* splitSelectors(selectors) | 41 function* splitSelectors(selectors) |
43 { | 42 { |
44 // Chromium's Blink engine supports only up to 8,192 simple selectors, and | 43 // Chromium's Blink engine supports only up to 8,192 simple selectors, and |
45 // even fewer compound selectors, in a rule. The exact number of selectors | 44 // even fewer compound selectors, in a rule. The exact number of selectors |
46 // that would work depends on their sizes (e.g. "#foo .bar" has a size of 2). | 45 // that would work depends on their sizes (e.g. "#foo .bar" has a size of 2). |
(...skipping 27 matching lines...) Expand all Loading... | |
74 browser.tabs.insertCSS(tabId, { | 73 browser.tabs.insertCSS(tabId, { |
75 code: styleSheet, | 74 code: styleSheet, |
76 cssOrigin: "user", | 75 cssOrigin: "user", |
77 frameId, | 76 frameId, |
78 matchAboutBlank: true, | 77 matchAboutBlank: true, |
79 runAt: "document_start" | 78 runAt: "document_start" |
80 }); | 79 }); |
81 } | 80 } |
82 catch (error) | 81 catch (error) |
83 { | 82 { |
84 if (/\bError processing cssOrigin\b/.test(error.message) == -1) | |
Sebastian Noack
2018/01/31 14:30:05
I wonder how safe the assumption is that this will
Manish Jethani
2018/02/01 08:05:07
OK, I think we should just look for /\bcssOrigin\b
Sebastian Noack
2018/02/01 10:32:50
I still think, we should just remove that check al
Manish Jethani
2018/02/01 10:40:38
Yeah I'm cool with just removing the check too. If
| |
85 throw error; | |
86 | |
87 userStyleSheetsSupported = false; | 83 userStyleSheetsSupported = false; |
88 } | 84 } |
89 | 85 |
90 return userStyleSheetsSupported; | 86 return userStyleSheetsSupported; |
91 } | 87 } |
92 | 88 |
93 function removeStyleSheet(tabId, frameId, styleSheet) | 89 function removeStyleSheet(tabId, frameId, styleSheet) |
94 { | 90 { |
95 if (!styleSheetRemovalSupported) | 91 if (!styleSheetRemovalSupported) |
96 return; | 92 return; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 response.inlineEmulated = true; | 173 response.inlineEmulated = true; |
178 | 174 |
179 return response; | 175 return response; |
180 }); | 176 }); |
181 | 177 |
182 port.on("elemhide.injectSelectors", (message, sender) => | 178 port.on("elemhide.injectSelectors", (message, sender) => |
183 { | 179 { |
184 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, | 180 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, |
185 message.groupName); | 181 message.groupName); |
186 }); | 182 }); |
LEFT | RIGHT |