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 |
(...skipping 16 matching lines...) Expand all Loading... |
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 |
30 // that rely on the order of their own <style> tags (#309) | 30 // that rely on the order of their own <style> tags (#309) |
31 if ("webkitCreateShadowRoot" in document.documentElement) | 31 if ("webkitCreateShadowRoot" in document.documentElement) |
32 { | 32 { |
33 var shadow = document.documentElement.webkitCreateShadowRoot(); | 33 var shadow = document.documentElement.webkitCreateShadowRoot(); |
34 shadow.appendChild(document.createElement("shadow")); | 34 shadow.appendChild(document.createElement("shadow")); |
35 shadow.appendChild(style); | 35 shadow.appendChild(style); |
36 | 36 |
37 for (var i = 0; i < selectors.length; i++) | 37 try |
38 selectors[i] = "::-webkit-distributed(" + selectors[i] + ")"; | 38 { |
| 39 document.querySelector("::content"); |
| 40 |
| 41 for (var i = 0; i < selectors.length; i++) |
| 42 selectors[i] = "::content " + selectors[i]; |
| 43 } |
| 44 catch (e) |
| 45 { |
| 46 for (var i = 0; i < selectors.length; i++) |
| 47 selectors[i] = "::-webkit-distributed(" + selectors[i] + ")"; |
| 48 } |
39 } | 49 } |
40 else | 50 else |
41 { | 51 { |
42 // Try to insert the style into the <head> tag, inserting directly under the | 52 // Try to insert the style into the <head> tag, inserting directly under the |
43 // document root breaks dev tools functionality: | 53 // document root breaks dev tools functionality: |
44 // http://code.google.com/p/chromium/issues/detail?id=178109 | 54 // http://code.google.com/p/chromium/issues/detail?id=178109 |
45 (document.head || document.documentElement).appendChild(style); | 55 (document.head || document.documentElement).appendChild(style); |
46 } | 56 } |
47 | 57 |
48 // WebKit apparently chokes when the selector list in a CSS rule is huge. | 58 // WebKit apparently chokes when the selector list in a CSS rule is huge. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ext.backgroundPage.sendMessage({type: "add-key-exception", token: attr}); | 121 ext.backgroundPage.sendMessage({type: "add-key-exception", token: attr}); |
112 | 122 |
113 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); | 123 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); |
114 } | 124 } |
115 | 125 |
116 // In Chrome 18 the document might not be initialized yet | 126 // In Chrome 18 the document might not be initialized yet |
117 if (document.documentElement) | 127 if (document.documentElement) |
118 init(); | 128 init(); |
119 else | 129 else |
120 window.setTimeout(init, 0); | 130 window.setTimeout(init, 0); |
OLD | NEW |