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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 { | 75 { |
76 // This element failed loading, did we block it? | 76 // This element failed loading, did we block it? |
77 var url = target.src; | 77 var url = target.src; |
78 if (!url) | 78 if (!url) |
79 return; | 79 return; |
80 | 80 |
81 ext.backgroundPage.sendMessage( | 81 ext.backgroundPage.sendMessage( |
82 { | 82 { |
83 type: "should-collapse", | 83 type: "should-collapse", |
84 url: url, | 84 url: url, |
85 documentUrl: document.URL, | |
86 mediatype: typeMap[tag] | 85 mediatype: typeMap[tag] |
87 }, | 86 }, |
88 | 87 |
89 function(response) | 88 function(response) |
90 { | 89 { |
91 if (response && target.parentNode) | 90 if (response && target.parentNode) |
92 { | 91 { |
93 // <frame> cannot be removed, doing that will mess up the frameset | 92 // <frame> cannot be removed, doing that will mess up the frameset |
94 if (tag == "frame") | 93 if (tag == "frame") |
95 target.style.setProperty("visibility", "hidden", "!important"); | 94 target.style.setProperty("visibility", "hidden", "!important"); |
96 else | 95 else |
97 target.parentNode.removeChild(target); | 96 target.parentNode.removeChild(target); |
98 } | 97 } |
99 } | 98 } |
100 ); | 99 ); |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 function init() | 103 function init() |
105 { | 104 { |
106 // Make sure this is really an HTML page, as Chrome runs these scripts on just
about everything | 105 // Make sure this is really an HTML page, as Chrome runs these scripts on just
about everything |
107 if (!(document.documentElement instanceof HTMLElement)) | 106 if (!(document.documentElement instanceof HTMLElement)) |
108 return; | 107 return; |
109 | 108 |
110 document.addEventListener("error", checkCollapse, true); | 109 document.addEventListener("error", checkCollapse, true); |
111 document.addEventListener("load", checkCollapse, true); | 110 document.addEventListener("load", checkCollapse, true); |
112 | 111 |
113 ext.backgroundPage.sendMessage( | 112 var attr = document.documentElement.getAttribute("data-adblockkey"); |
114 { | 113 if (attr) |
115 type: "get-selectors", | 114 ext.backgroundPage.sendMessage({type: "add-key-exception", token: attr}); |
116 frameUrl: window.location.href | 115 |
117 }, | 116 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); |
118 setElemhideCSSRules | |
119 ); | |
120 } | 117 } |
121 | 118 |
122 // In Chrome 18 the document might not be initialized yet | 119 // In Chrome 18 the document might not be initialized yet |
123 if (document.documentElement) | 120 if (document.documentElement) |
124 init(); | 121 init(); |
125 else | 122 else |
126 window.setTimeout(init, 0); | 123 window.setTimeout(init, 0); |
OLD | NEW |