OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the Adblock Plus extension, | 2 * This file is part of the Adblock Plus extension, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 12 matching lines...) Expand all Loading... |
23 function setElemhideCSSRules(selectors) | 23 function setElemhideCSSRules(selectors) |
24 { | 24 { |
25 if (elemhideElt && elemhideElt.parentNode) | 25 if (elemhideElt && elemhideElt.parentNode) |
26 elemhideElt.parentNode.removeChild(elemhideElt); | 26 elemhideElt.parentNode.removeChild(elemhideElt); |
27 | 27 |
28 if (!selectors) | 28 if (!selectors) |
29 return; | 29 return; |
30 | 30 |
31 elemhideElt = document.createElement("style"); | 31 elemhideElt = document.createElement("style"); |
32 elemhideElt.setAttribute("type", "text/css"); | 32 elemhideElt.setAttribute("type", "text/css"); |
33 document.documentElement.appendChild(elemhideElt); | 33 |
| 34 // Try to insert the style into the <head> tag, inserting directly under the |
| 35 // document root breaks dev tools functionality: |
| 36 // http://code.google.com/p/chromium/issues/detail?id=178109 |
| 37 (document.head || document.documentElement).appendChild(elemhideElt); |
34 | 38 |
35 var elt = elemhideElt; // Use a local variable to avoid racing conditions | 39 var elt = elemhideElt; // Use a local variable to avoid racing conditions |
36 function setRules() | 40 function setRules() |
37 { | 41 { |
38 if (!elt.sheet) | 42 if (!elt.sheet) |
39 { | 43 { |
40 // Stylesheet didn't initialize yet, wait a little longer | 44 // Stylesheet didn't initialize yet, wait a little longer |
41 window.setTimeout(setRules, 0); | 45 window.setTimeout(setRules, 0); |
42 return; | 46 return; |
43 } | 47 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 { | 98 { |
95 setElemhideCSSRules(response.selectors); | 99 setElemhideCSSRules(response.selectors); |
96 }); | 100 }); |
97 } | 101 } |
98 | 102 |
99 // In Chrome 18 the document might not be initialized yet | 103 // In Chrome 18 the document might not be initialized yet |
100 if (document.documentElement) | 104 if (document.documentElement) |
101 init(); | 105 init(); |
102 else | 106 else |
103 window.setTimeout(init, 0); | 107 window.setTimeout(init, 0); |
OLD | NEW |