| 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; | |
| 166 let generichide = null; | |
| 167 | |
| 165 if (!match && Prefs.enabled) | 168 if (!match && Prefs.enabled) |
| 166 { | 169 { |
| 167 let testWnd = wnd; | 170 let testWnd = wnd; |
| 168 let testSitekey = sitekey; | 171 let testSitekey = sitekey; |
| 169 let testSitekeyWnd = sitekeyWnd; | 172 let testSitekeyWnd = sitekeyWnd; |
| 170 let parentWndLocation = getWindowLocation(testWnd); | 173 let parentWndLocation = getWindowLocation(testWnd); |
| 171 while (true) | 174 while (true) |
| 172 { | 175 { |
| 173 let testWndLocation = parentWndLocation; | 176 let testWndLocation = parentWndLocation; |
| 174 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 177 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); |
| 175 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); | 178 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); |
| 176 | 179 |
| 177 if (match instanceof WhitelistFilter) | 180 if (match instanceof WhitelistFilter) |
| 178 { | 181 { |
| 179 FilterStorage.increaseHitCount(match, wnd); | 182 FilterStorage.increaseHitCount(match, wnd); |
| 180 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); | 183 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); |
| 181 return true; | 184 return true; |
| 182 } | 185 } |
| 186 else if (contentType != Policy.type.ELEMHIDE) | |
|
Thomas Greiner
2015/08/28 10:28:24
Detail: The "else" keyword is redundant here due t
kzar
2015/09/03 12:37:02
Done.
| |
| 187 { | |
| 188 let parentDocDomain = getHostname(parentWndLocation); | |
| 189 let genericblockMatch = defaultMatcher.matchesAny( | |
| 190 testWndLocation, RegExpFilter.typeMap.GENERICBLOCK, | |
| 191 parentDocDomain, false, testSitekey | |
| 192 ); | |
| 193 if (genericblockMatch instanceof WhitelistFilter) | |
| 194 { | |
| 195 genericblock = { | |
| 196 match: genericblockMatch, | |
| 197 parentDocDomain: parentDocDomain, | |
| 198 testWnd: testWnd, | |
| 199 testWndLocation: testWndLocation | |
| 200 }; | |
| 201 } | |
| 202 } | |
| 183 | 203 |
| 184 if (testWnd.parent == testWnd) | 204 if (testWnd.parent == testWnd) |
| 185 break; | 205 break; |
| 186 | 206 |
| 187 if (testWnd == testSitekeyWnd) | 207 if (testWnd == testSitekeyWnd) |
| 188 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); | 208 [testSitekey, testSitekeyWnd] = getSitekey(testWnd.parent); |
| 189 testWnd = testWnd.parent; | 209 testWnd = testWnd.parent; |
| 190 } | 210 } |
| 191 } | 211 } |
| 192 | 212 |
| 193 // Data loaded by plugins should be attached to the document | 213 // Data loaded by plugins should be attached to the document |
| 194 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) | 214 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) |
| 195 node = node.ownerDocument; | 215 node = node.ownerDocument; |
| 196 | 216 |
| 197 // Fix type for objects misrepresented as frames or images | 217 // Fix type for objects misrepresented as frames or images |
| 198 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) | 218 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) |
| 199 contentType = Policy.type.OBJECT; | 219 contentType = Policy.type.OBJECT; |
| 200 | 220 |
| 201 let locationText = location.spec; | 221 let locationText = location.spec; |
| 202 if (!match && contentType == Policy.type.ELEMHIDE) | 222 if (!match && contentType == Policy.type.ELEMHIDE) |
| 203 { | 223 { |
| 204 let testWnd = wnd; | 224 let testWnd = wnd; |
| 205 let parentWndLocation = getWindowLocation(testWnd); | 225 let parentWndLocation = getWindowLocation(testWnd); |
| 206 while (true) | 226 while (true) |
| 207 { | 227 { |
| 208 let testWndLocation = parentWndLocation; | 228 let testWndLocation = parentWndLocation; |
| 209 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 229 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); |
| 210 let parentDocDomain = getHostname(parentWndLocation); | 230 let parentDocDomain = getHostname(parentWndLocation); |
| 231 | |
| 211 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); | 232 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); |
| 233 | |
| 212 if (match instanceof WhitelistFilter) | 234 if (match instanceof WhitelistFilter) |
| 213 { | 235 { |
| 214 FilterStorage.increaseHitCount(match, wnd); | 236 FilterStorage.increaseHitCount(match, wnd); |
| 215 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); | 237 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); |
| 216 return true; | 238 return true; |
| 217 } | 239 } |
| 218 | 240 |
| 241 let generichideMatch = defaultMatcher.matchesAny( | |
| 242 testWndLocation, RegExpFilter.typeMap.GENERICHIDE, | |
| 243 parentDocDomain, false, sitekey | |
| 244 ); | |
| 245 if (generichideMatch instanceof WhitelistFilter) | |
| 246 { | |
| 247 generichide = { | |
| 248 match: generichideMatch, | |
| 249 parentDocDomain: parentDocDomain, | |
| 250 testWnd: testWnd, | |
| 251 testWndLocation: testWndLocation | |
| 252 }; | |
| 253 } | |
| 254 | |
| 219 if (testWnd.parent == testWnd) | 255 if (testWnd.parent == testWnd) |
| 220 break; | 256 break; |
| 221 else | 257 else |
| 222 testWnd = testWnd.parent; | 258 testWnd = testWnd.parent; |
| 223 } | 259 } |
| 224 | 260 |
| 225 match = location; | 261 match = location; |
| 226 locationText = match.text.replace(/^.*?#/, '#'); | 262 locationText = match.text.replace(/^.*?#/, '#'); |
| 227 location = locationText; | 263 location = locationText; |
| 228 | 264 |
| 229 if (!match.isActiveOnDomain(docDomain)) | 265 if (!match.isActiveOnDomain(docDomain)) |
| 230 return true; | 266 return true; |
| 231 | 267 |
| 232 let exception = ElemHide.getException(match, docDomain); | 268 let exception = ElemHide.getException(match, docDomain); |
| 233 if (exception) | 269 if (exception) |
| 234 { | 270 { |
| 235 FilterStorage.increaseHitCount(exception, wnd); | 271 FilterStorage.increaseHitCount(exception, wnd); |
| 236 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); | 272 RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception); |
| 237 return true; | 273 return true; |
| 238 } | 274 } |
| 275 | |
| 276 if (match && match.isGeneric() && generichide) | |
|
Thomas Greiner
2015/08/28 10:28:24
I'd assume that checking for "generichide" first w
kzar
2015/09/03 12:37:02
Done.
| |
| 277 { | |
| 278 FilterStorage.increaseHitCount(generichide.match, wnd); | |
| 279 RequestNotifier.addNodeData( | |
| 280 generichide.testWnd.document, | |
| 281 topWnd, contentType, | |
| 282 generichide.parentDocDomain, | |
| 283 false, generichide.testWndLocation, | |
| 284 generichide.match | |
| 285 ); | |
| 286 return true; | |
| 287 } | |
| 239 } | 288 } |
| 240 | 289 |
| 241 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); | 290 let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty (location, docDomain)); |
| 242 | 291 |
| 243 if (!match && Prefs.enabled && contentType in Policy.typeMask) | 292 if (!match && Prefs.enabled && contentType in Policy.typeMask) |
| 244 { | 293 { |
| 245 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], docDomain, thirdParty, sitekey); | 294 match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentTyp e], docDomain, thirdParty, sitekey); |
| 246 if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) | 295 if (match instanceof BlockingFilter) |
| 247 { | 296 { |
| 248 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fas tcollapse); | 297 if (match.isGeneric() && genericblock) |
| 249 if (collapse || prefCollapse) | 298 { |
| 250 schedulePostProcess(node); | 299 FilterStorage.increaseHitCount(genericblock.match, wnd); |
| 300 RequestNotifier.addNodeData( | |
| 301 genericblock.testWnd.document, | |
| 302 topWnd, contentType, | |
| 303 genericblock.parentDocDomain, | |
| 304 false, genericblock.testWndLocation, | |
| 305 genericblock.match | |
| 306 ); | |
| 307 return true; | |
| 308 } | |
| 309 | |
| 310 if (node.ownerDocument && !(contentType in Policy.nonVisual)) | |
| 311 { | |
| 312 let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.f astcollapse); | |
| 313 if (collapse || prefCollapse) | |
| 314 schedulePostProcess(node); | |
| 315 } | |
| 251 } | 316 } |
| 252 | 317 |
| 253 // Track mouse events for objects | 318 // Track mouse events for objects |
| 254 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) | 319 if (!match && contentType == Policy.type.OBJECT && node.nodeType == Ci.nsI DOMNode.ELEMENT_NODE) |
| 255 { | 320 { |
| 256 node.addEventListener("mouseover", objectMouseEventHander, true); | 321 node.addEventListener("mouseover", objectMouseEventHander, true); |
| 257 node.addEventListener("mouseout", objectMouseEventHander, true); | 322 node.addEventListener("mouseout", objectMouseEventHander, true); |
| 258 } | 323 } |
| 259 } | 324 } |
| 260 | 325 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 if (!wnd || wnd.closed) | 860 if (!wnd || wnd.closed) |
| 796 return; | 861 return; |
| 797 | 862 |
| 798 if (entry.type == Policy.type.OBJECT) | 863 if (entry.type == Policy.type.OBJECT) |
| 799 { | 864 { |
| 800 node.removeEventListener("mouseover", objectMouseEventHander, true); | 865 node.removeEventListener("mouseover", objectMouseEventHander, true); |
| 801 node.removeEventListener("mouseout", objectMouseEventHander, true); | 866 node.removeEventListener("mouseout", objectMouseEventHander, true); |
| 802 } | 867 } |
| 803 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 868 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
| 804 } | 869 } |
| OLD | NEW |