OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 var SELECTOR_GROUP_SIZE = 20; | 18 var SELECTOR_GROUP_SIZE = 20; |
19 | 19 |
20 // Sets the currently used CSS rules for elemhide filters | 20 // Sets the currently used CSS rules for elemhide filters |
21 function setElemhideCSSRules(selectors) | 21 function setElemhideCSSRules(selectors) |
22 { | 22 { |
23 if (selectors.length == 0) | 23 if (selectors.length == 0) |
24 return; | 24 return; |
25 | 25 |
26 var style = document.createElement("style"); | 26 var style = document.createElement("style"); |
27 style.setAttribute("type", "text/css"); | 27 style.setAttribute("type", "text/css"); |
28 | 28 |
29 // Use Shadow DOM if available to don't mess with web pages | 29 // Use Shadow DOM if available to don't mess with web pages that |
30 // that rely on the order of their own <style> tags (#309) | 30 // rely on the order of their own <style> tags. However |
31 if ("webkitCreateShadowRoot" in document.documentElement) | 31 // the <shadow> element is broken in Chrome 32.0.1700 (#309) |
| 32 if ("webkitCreateShadowRoot" in document.documentElement && !/\bChrome\/32\.0\
.1700\b/.test(navigator.userAgent)) |
32 { | 33 { |
33 var shadow = document.documentElement.webkitCreateShadowRoot(); | 34 var shadow = document.documentElement.webkitCreateShadowRoot(); |
34 shadow.appendChild(document.createElement("shadow")); | 35 shadow.appendChild(document.createElement("shadow")); |
35 shadow.appendChild(style); | 36 shadow.appendChild(style); |
36 | 37 |
37 try | 38 try |
38 { | 39 { |
39 document.querySelector("::content"); | 40 document.querySelector("::content"); |
40 | 41 |
41 for (var i = 0; i < selectors.length; i++) | 42 for (var i = 0; i < selectors.length; i++) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ext.backgroundPage.sendMessage({type: "add-key-exception", token: attr}); | 122 ext.backgroundPage.sendMessage({type: "add-key-exception", token: attr}); |
122 | 123 |
123 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); | 124 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); |
124 } | 125 } |
125 | 126 |
126 // In Chrome 18 the document might not be initialized yet | 127 // In Chrome 18 the document might not be initialized yet |
127 if (document.documentElement) | 128 if (document.documentElement) |
128 init(); | 129 init(); |
129 else | 130 else |
130 window.setTimeout(init, 0); | 131 window.setTimeout(init, 0); |
OLD | NEW |