| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 if (!topWnd || !topWnd.location || !topWnd.location.href) | 167 if (!topWnd || !topWnd.location || !topWnd.location.href) |
| 168 return true; | 168 return true; |
| 169 | 169 |
| 170 let originWindow = Utils.getOriginWindow(wnd); | 170 let originWindow = Utils.getOriginWindow(wnd); |
| 171 let wndLocation = originWindow.location.href; | 171 let wndLocation = originWindow.location.href; |
| 172 let docDomain = getHostname(wndLocation); | 172 let docDomain = getHostname(wndLocation); |
| 173 let match = null; | 173 let match = null; |
| 174 let [sitekey, sitekeyWnd] = getSitekey(wnd); | 174 let [sitekey, sitekeyWnd] = getSitekey(wnd); |
| 175 let nogeneric = false; | 175 let nogeneric = false; |
| 176 | 176 |
| 177 function cleanWindowLocation(wnd) | |
|
Thomas Greiner
2015/11/10 18:22:33
This function doesn't need to be inside `processNo
Wladimir Palant
2015/11/10 19:13:15
Given that this is a temporary solution I'd rather
| |
| 178 { | |
| 179 let url = getWindowLocation(wnd); | |
| 180 let index = url.indexOf("#"); | |
| 181 if (index >= 0) | |
| 182 url = url.substring(0, index); | |
| 183 | |
| 184 return url; | |
| 185 } | |
| 186 | |
| 177 if (!match && Prefs.enabled) | 187 if (!match && Prefs.enabled) |
| 178 { | 188 { |
| 179 let testWnd = wnd; | 189 let testWnd = wnd; |
| 180 let testSitekey = sitekey; | 190 let testSitekey = sitekey; |
| 181 let testSitekeyWnd = sitekeyWnd; | 191 let testSitekeyWnd = sitekeyWnd; |
| 182 let parentWndLocation = getWindowLocation(testWnd); | 192 let parentWndLocation = cleanWindowLocation(testWnd); |
| 183 while (true) | 193 while (true) |
| 184 { | 194 { |
| 185 let testWndLocation = parentWndLocation; | 195 let testWndLocation = parentWndLocation; |
| 186 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | 196 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : clean WindowLocation(testWnd.parent)); |
| 187 match = Policy.isWhitelisted(testWndLocation, parentWndLocation, testSit ekey); | 197 let parentDocDomain = getHostname(parentWndLocation); |
| 188 | 198 |
| 189 if (match instanceof WhitelistFilter) | 199 let typeMap = RegExpFilter.typeMap.DOCUMENT; |
| 200 if (contentType == Policy.type.ELEMHIDE) | |
| 201 typeMap = typeMap | RegExpFilter.typeMap.ELEMHIDE; | |
| 202 let whitelistMatch = defaultMatcher.matchesAny(testWndLocation, typeMap, parentDocDomain, false, sitekey); | |
|
Thomas Greiner
2015/11/10 18:22:34
`sitekey` is the bottom window's sitekey so should
Wladimir Palant
2015/11/10 19:13:15
Yes, this should really be testSitekey - this was
Wladimir Palant
2015/11/11 07:54:20
Done.
| |
| 203 if (whitelistMatch instanceof WhitelistFilter) | |
| 190 { | 204 { |
| 191 FilterStorage.increaseHitCount(match, wnd); | 205 FilterStorage.increaseHitCount(whitelistMatch, wnd); |
| 192 RequestNotifier.addNodeData(testWnd.document, topWnd, Policy.type.DOCU MENT, getHostname(parentWndLocation), false, testWndLocation, match); | 206 RequestNotifier.addNodeData(testWnd.document, topWnd, |
| 207 (whitelistMatch.contentType & RegExpFilter.typeMap.DOCUMENT) ? Polic y.type.DOCUMENT : Policy.type.ELEMHIDE, | |
| 208 parentDocDomain, false, testWndLocation, whitelistMatch); | |
| 193 return true; | 209 return true; |
| 194 } | 210 } |
| 195 | 211 |
| 196 let genericType = (contentType == Policy.type.ELEMHIDE ? | 212 let genericType = (contentType == Policy.type.ELEMHIDE ? |
| 197 Policy.type.GENERICHIDE : | 213 Policy.type.GENERICHIDE : |
| 198 Policy.type.GENERICBLOCK); | 214 Policy.type.GENERICBLOCK); |
| 199 let parentDocDomain = getHostname(parentWndLocation); | |
| 200 let nogenericMatch = defaultMatcher.matchesAny(testWndLocation, | 215 let nogenericMatch = defaultMatcher.matchesAny(testWndLocation, |
| 201 Policy.typeMask[genericType], parentDocDomain, false, testSitekey); | 216 Policy.typeMask[genericType], parentDocDomain, false, testSitekey); |
| 202 if (nogenericMatch instanceof WhitelistFilter) | 217 if (nogenericMatch instanceof WhitelistFilter) |
| 203 { | 218 { |
| 204 nogeneric = true; | 219 nogeneric = true; |
| 205 | 220 |
| 206 FilterStorage.increaseHitCount(nogenericMatch, wnd); | 221 FilterStorage.increaseHitCount(nogenericMatch, wnd); |
| 207 RequestNotifier.addNodeData(testWnd.document, topWnd, genericType, | 222 RequestNotifier.addNodeData(testWnd.document, topWnd, genericType, |
| 208 parentDocDomain, false, testWndLocation, | 223 parentDocDomain, false, testWndLocation, |
| 209 nogenericMatch); | 224 nogenericMatch); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 222 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) | 237 if (contentType == Policy.type.OBJECT_SUBREQUEST && node instanceof Ci.nsIDO MElement) |
| 223 node = node.ownerDocument; | 238 node = node.ownerDocument; |
| 224 | 239 |
| 225 // Fix type for objects misrepresented as frames or images | 240 // Fix type for objects misrepresented as frames or images |
| 226 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) | 241 if (contentType != Policy.type.OBJECT && (node instanceof Ci.nsIDOMHTMLObjec tElement || node instanceof Ci.nsIDOMHTMLEmbedElement)) |
| 227 contentType = Policy.type.OBJECT; | 242 contentType = Policy.type.OBJECT; |
| 228 | 243 |
| 229 let locationText = location.spec; | 244 let locationText = location.spec; |
| 230 if (!match && contentType == Policy.type.ELEMHIDE) | 245 if (!match && contentType == Policy.type.ELEMHIDE) |
| 231 { | 246 { |
| 232 let testWnd = wnd; | |
| 233 let parentWndLocation = getWindowLocation(testWnd); | |
| 234 while (true) | |
| 235 { | |
| 236 let testWndLocation = parentWndLocation; | |
| 237 parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWi ndowLocation(testWnd.parent)); | |
| 238 let parentDocDomain = getHostname(parentWndLocation); | |
| 239 match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap. ELEMHIDE, parentDocDomain, false, sitekey); | |
| 240 if (match instanceof WhitelistFilter) | |
| 241 { | |
| 242 FilterStorage.increaseHitCount(match, wnd); | |
| 243 RequestNotifier.addNodeData(testWnd.document, topWnd, contentType, par entDocDomain, false, testWndLocation, match); | |
| 244 return true; | |
| 245 } | |
| 246 | |
| 247 if (testWnd.parent == testWnd) | |
| 248 break; | |
| 249 else | |
| 250 testWnd = testWnd.parent; | |
| 251 } | |
| 252 | |
| 253 match = location; | 247 match = location; |
| 254 locationText = match.text.replace(/^.*?#/, '#'); | 248 locationText = match.text.replace(/^.*?#/, '#'); |
| 255 location = locationText; | 249 location = locationText; |
| 256 | 250 |
| 257 if (!match.isActiveOnDomain(docDomain)) | 251 if (!match.isActiveOnDomain(docDomain)) |
| 258 return true; | 252 return true; |
| 259 | 253 |
| 260 let exception = ElemHide.getException(match, docDomain); | 254 let exception = ElemHide.getException(match, docDomain); |
| 261 if (exception) | 255 if (exception) |
| 262 { | 256 { |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 if (!wnd || wnd.closed) | 719 if (!wnd || wnd.closed) |
| 726 return; | 720 return; |
| 727 | 721 |
| 728 if (entry.type == Policy.type.OBJECT) | 722 if (entry.type == Policy.type.OBJECT) |
| 729 { | 723 { |
| 730 node.removeEventListener("mouseover", objectMouseEventHander, true); | 724 node.removeEventListener("mouseover", objectMouseEventHander, true); |
| 731 node.removeEventListener("mouseout", objectMouseEventHander, true); | 725 node.removeEventListener("mouseout", objectMouseEventHander, true); |
| 732 } | 726 } |
| 733 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 727 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
| 734 } | 728 } |
| OLD | NEW |