Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include.postload.js

Issue 5945877571043328: Issue 705 - Generate element hiding instead request blocking filters for non-HTTP URLs (Closed)
Patch Set: Rebased Created Oct. 30, 2014, 4:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 var selector = ""; 401 var selector = "";
402 402
403 for (var i = 0; i < elt.classList.length; i++) 403 for (var i = 0; i < elt.classList.length; i++)
404 selector += "." + elt.classList[i].replace(/([^\w-])/, "\\$1"); 404 selector += "." + elt.classList[i].replace(/([^\w-])/, "\\$1");
405 405
406 addSelector(selector); 406 addSelector(selector);
407 } 407 }
408 408
409 if (url) 409 if (url)
410 { 410 {
411 clickHideFilters.push(url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||")); 411 var src = elt.getAttribute("src");
412 var selector = src && elt.localName + '[src=' + quote(src) + ']';
Wladimir Palant 2014/10/30 22:36:28 elt.localName still needs escaping, DOM methods al
Sebastian Noack 2014/10/31 13:52:49 The syntax for valid tag names is very restrictive
Wladimir Palant 2014/11/03 18:14:28 document.createElement("foo:bar") might still be p
412 413
413 var src = elt.getAttribute("src"); 414 if (/^https?:/i.test(url))
414 if (src) 415 {
415 selectorList.push('[src=' + quote(src) + ']'); 416 clickHideFilters.push(url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"));
417
418 if (selector)
419 selectorList.push(selector);
420 }
421 else if (selector)
422 addSelector(selector);
416 } 423 }
417 424
418 // restore the original style, before generating the fallback filter that 425 // restore the original style, before generating the fallback filter that
419 // will include the style, and to prevent highlightElements from saving those 426 // will include the style, and to prevent highlightElements from saving those
420 unhighlightElement(currentElement); 427 unhighlightElement(currentElement);
421 428
422 // as last resort, create a filter based on inline styles 429 // as last resort, create a filter based on inline styles
423 if (clickHideFilters.length == 0) 430 if (clickHideFilters.length == 0)
424 { 431 {
425 var style = elt.getAttribute("style"); 432 var style = elt.getAttribute("style");
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 break; 659 break;
653 default: 660 default:
654 sendResponse({}); 661 sendResponse({});
655 break; 662 break;
656 } 663 }
657 }); 664 });
658 665
659 if (window == window.top) 666 if (window == window.top)
660 ext.backgroundPage.sendMessage({type: "report-html-page"}); 667 ext.backgroundPage.sendMessage({type: "report-html-page"});
661 } 668 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld