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