Left: | ||
Right: |
OLD | NEW |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 { | 155 { |
156 let topWnd = wnd.top; | 156 let topWnd = wnd.top; |
157 if (!topWnd || !topWnd.location || !topWnd.location.href) | 157 if (!topWnd || !topWnd.location || !topWnd.location.href) |
158 return true; | 158 return true; |
159 | 159 |
160 let originWindow = Utils.getOriginWindow(wnd); | 160 let originWindow = Utils.getOriginWindow(wnd); |
161 let wndLocation = originWindow.location.href; | 161 let wndLocation = originWindow.location.href; |
162 let docDomain = getHostname(wndLocation); | 162 let docDomain = getHostname(wndLocation); |
163 let match = null; | 163 let match = null; |
164 let [sitekey, sitekeyWnd] = getSitekey(wnd); | 164 let [sitekey, sitekeyWnd] = getSitekey(wnd); |
165 let genericblock = null; | |
165 if (!match && Prefs.enabled) | 166 if (!match && Prefs.enabled) |
166 { | 167 { |
167 let testWnd = wnd; | 168 let testWnd = wnd; |
168 let testSitekey = sitekey; | 169 let testSitekey = sitekey; |
169 let testSitekeyWnd = sitekeyWnd; | 170 let testSitekeyWnd = sitekeyWnd; |
170 let parentWndLocation = getWindowLocation(testWnd); | 171 let parentWndLocation = getWindowLocation(testWnd); |
171 while (true) | 172 while (true) |
172 { | 173 { |
173 let testWndLocation = parentWndLocation; | 174 let testWndLocation = parentWndLocation; |
174 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 175 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); |
175 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); | 176 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); |
176 | 177 |
177 if (match instanceof WhitelistFilter) | 178 if (match instanceof WhitelistFilter) |
178 { | 179 { |
179 FilterStorage.increaseHitCount(match, wnd); | 180 FilterStorage.increaseHitCount(match, wnd); |
180 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); | 181 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); |
181 return true; | 182 return true; |
182 } | 183 } |
184 else if (contentType != Policy.type.ELEMHIDE) | |
185 { | |
186 let parentDocDomain = getHostname(parentWndLocation); | |
187 let genericblock_match = defaultMatcher.matchesAny(testWndLocation, Re gExpFilter.typeMap.GENERICBLOCK, parentDocDomain, false); | |
Sebastian Noack
2015/07/15 14:57:19
Nit: camelcase?
kzar
2015/07/15 15:10:41
Done.
| |
188 if (genericblock_match instanceof WhitelistFilter) | |
189 { | |
Sebastian Noack
2015/07/15 14:57:19
Nit: Feel free to remove the redundant braces. Tho
kzar
2015/07/15 15:10:41
I think in this instance it looks nicer with them.
| |
190 genericblock = { | |
191 match: genericblock_match, | |
192 parentDocDomain: parentDocDomain, | |
193 testWnd: testWnd, | |
194 testWndLocation: testWndLocation | |
195 }; | |
196 } | |
197 } | |
183 | 198 |
184 if (testWnd.parent == testWnd) | 199 if (testWnd.parent == testWnd) |
185 break; | 200 break; |
186 | 201 |
187 if (testWnd == testSitekeyWnd) | 202 if (testWnd == testSitekeyWnd) |
188 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); | 203 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); |
189 testWnd = testWnd.parent; | 204 testWnd = testWnd.parent; |
190 } | 205 } |
191 } | 206 } |
192 | 207 |
193 // Data loaded by plugins should be attached to the document | 208 // Data loaded by plugins should be attached to the document |
194 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) | 209 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) |
195 node = node.ownerDocument; | 210 node = node.ownerDocument; |
196 | 211 |
197 // Fix type for objects misrepresented as frames or images | 212 // Fix type for objects misrepresented as frames or images |
198 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) | 213 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) |
199 contentType = Policy.type.OBJECT; | 214 contentType = Policy.type.OBJECT; |
200 | 215 |
201 let locationText = location.spec; | 216 let locationText = location.spec; |
202 if (!match && contentType == Policy.type.ELEMHIDE) | 217 if (!match && contentType == Policy.type.ELEMHIDE) |
203 { | 218 { |
204 let testWnd = wnd; | 219 let testWnd = wnd; |
205 let parentWndLocation = getWindowLocation(testWnd); | 220 let parentWndLocation = getWindowLocation(testWnd); |
206 while (true) | 221 while (true) |
207 { | 222 { |
208 let testWndLocation = parentWndLocation; | 223 let testWndLocation = parentWndLocation; |
209 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 224 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); |
210 let parentDocDomain = getHostname(parentWndLocation); | 225 let parentDocDomain = getHostname(parentWndLocation); |
226 | |
211 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); | 227 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); |
228 | |
229 if (!(match instanceof WhitelistFilter) && (!location.domains || locatio n.domains[""])) | |
230 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMa p.GENERICHIDE, parentDocDomain, false); | |
231 | |
212 if (match instanceof WhitelistFilter) | 232 if (match instanceof WhitelistFilter) |
213 { | 233 { |
214 FilterStorage.increaseHitCount(match, wnd); | 234 FilterStorage.increaseHitCount(match, wnd); |
215 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); | 235 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); |
216 return true; | 236 return true; |
217 } | 237 } |
218 | 238 |
219 if (testWnd.parent == testWnd) | 239 if (testWnd.parent == testWnd) |
220 break; | 240 break; |
221 else | 241 else |
(...skipping 14 matching lines...) Expand all Loading... | |
236 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); | 256 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); |
237 return true; | 257 return true; |
238 } | 258 } |
239 } | 259 } |
240 | 260 |
241 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); | 261 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); |
242 | 262 |
243 if (!match && Prefs.enabled && contentType in Policy.typeMask) | 263 if (!match && Prefs.enabled && contentType in Policy.typeMask) |
244 { | 264 { |
245 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], docDomain, thirdParty, sitekey); | 265 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], docDomain, thirdParty, sitekey); |
246 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) | 266 if (match instanceof BlockingFilter) |
247 { | 267 { |
248 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); | 268 if ((!match.domains || match.domains[""]) && genericblock) |
249 if (collapse || prefCollapse) | 269 { |
250 schedulePostProcess(node); | 270 FilterStorage.increaseHitCount(genericblock.match, wnd); |
271 RequestNotifier.addNodeData( | |
272 genericblock.testWnd.document, | |
273 topWnd, contentType, | |
274 genericblock.parentDocDomain, | |
275 false, genericblock.testWndLocation, | |
276 genericblock.match | |
277 ); | |
278 return true; | |
279 } | |
280 | |
281 if (node.ownerDocument && !(contentType in Policy.nonVisual)) | |
282 { | |
283 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.f astcollapse); | |
284 if (collapse || prefCollapse) | |
285 schedulePostProcess(node); | |
286 } | |
251 } | 287 } |
252 | 288 |
253 // Track mouse events for objects | 289 // Track mouse events for objects |
254 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) | 290 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) |
255 { | 291 { |
256 node.addEventListener("mouseover", objectMouseEventHander, true); | 292 node.addEventListener("mouseover", objectMouseEventHander, true); |
257 node.addEventListener("mouseout", objectMouseEventHander, true); | 293 node.addEventListener("mouseout", objectMouseEventHander, true); |
258 } | 294 } |
259 } | 295 } |
260 | 296 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 if (!wnd || wnd.closed) | 831 if (!wnd || wnd.closed) |
796 return; | 832 return; |
797 | 833 |
798 if (entry.type == Policy.type.OBJECT) | 834 if (entry.type == Policy.type.OBJECT) |
799 { | 835 { |
800 node.removeEventListener("mouseover", objectMouseEventHander, true); | 836 node.removeEventListener("mouseover", objectMouseEventHander, true); |
801 node.removeEventListener("mouseout", objectMouseEventHander, true); | 837 node.removeEventListener("mouseout", objectMouseEventHander, true); |
802 } | 838 } |
803 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 839 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
804 } | 840 } |
OLD | NEW |