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

Delta Between Two Patch Sets: include.postload.js

Issue 5132310882025472: Issue 704 - Generate protocol-agnostic request blocking filters with "Block element" (Closed)
Left Patch Set: Rebased and simplified changes Created Sept. 25, 2014, 8:28 a.m.
Right Patch Set: Addressed comments Created Oct. 1, 2014, 6:10 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 var selector = elementClasses.map(function(elClass) 384 var selector = elementClasses.map(function(elClass)
385 { 385 {
386 return "." + elClass.replace(/([^\w-])/, "\\$1"); 386 return "." + elClass.replace(/([^\w-])/, "\\$1");
387 }).join(""); 387 }).join("");
388 388
389 clickHideFilters.push(document.domain + "##" + selector); 389 clickHideFilters.push(document.domain + "##" + selector);
390 selectorList.push(selector); 390 selectorList.push(selector);
391 } 391 }
392 if (url) 392 if (url)
393 { 393 {
394 clickHideFilters.push(url.replace(/.*?:\/\//, '||')); 394 clickHideFilters.push(url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"));
Thomas Greiner 2014/09/30 11:10:53 Nit: Use double instead of single quotation marks
Wladimir Palant 2014/10/01 18:00:45 It makes sense to use the same regular expression
Sebastian Noack 2014/10/01 18:10:55 Done.
Sebastian Noack 2014/10/01 18:10:55 Done.
395 selectorList.push(elt.localName + '[src="' + elt.getAttribute("src") + '"]') ; 395 selectorList.push('[src="' + elt.getAttribute("src") + '"]');
Wladimir Palant 2014/10/01 18:00:45 Please remove this line, your previous patch did t
Sebastian Noack 2014/10/01 18:10:55 How do you mean? I didn't add this line, I just fi
Wladimir Palant 2014/10/01 18:26:51 As mentioned before, a hiding filter based on the
Sebastian Noack 2014/10/01 18:33:16 We don't generate a filer here. This list is only
396 } 396 }
397 397
398 // Show popup 398 // Show popup
399 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); 399 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters);
400 400
401 // Highlight the unlucky elements 401 // Highlight the unlucky elements
402 // Restore currentElement's box-shadow and bgcolor so that highlightElements w on't save those 402 // Restore currentElement's box-shadow and bgcolor so that highlightElements w on't save those
403 unhighlightElement(currentElement); 403 unhighlightElement(currentElement);
404 // Highlight the elements specified by selector in yellow 404 // Highlight the elements specified by selector in yellow
405 highlightElements(selectorList.join(",")); 405 highlightElements(selectorList.join(","));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 u = m[2]; 458 u = m[2];
459 r = r + m[1]; 459 r = r + m[1];
460 } 460 }
461 } 461 }
462 return r; 462 return r;
463 } else { 463 } else {
464 return u; 464 return u;
465 } 465 }
466 } 466 }
467 467
468 // Content scripts are apparently invoked on non-HTML documents, so we have to 468 if (document instanceof HTMLDocument)
469 // check for that before doing stuff. |document instanceof HTMLDocument| check
470 // will fail on some sites like planet.mozilla.org because WebKit creates
471 // Document instances for XHTML documents, have to test the root element.
472 if (document.documentElement instanceof HTMLElement)
473 { 469 {
474 // Use a contextmenu handler to save the last element the user right-clicked o n. 470 // Use a contextmenu handler to save the last element the user right-clicked o n.
475 // To make things easier, we actually save the DOM event. 471 // To make things easier, we actually save the DOM event.
476 // We have to do this because the contextMenu API only provides a URL, not the actual 472 // We have to do this because the contextMenu API only provides a URL, not the actual
477 // DOM element. 473 // DOM element.
478 document.addEventListener('contextmenu', function(e) { 474 document.addEventListener('contextmenu', function(e) {
479 lastRightClickEvent = e; 475 lastRightClickEvent = e;
480 }, false); 476 }, false);
481 477
482 document.addEventListener("click", function(event) 478 document.addEventListener("click", function(event)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 currentElement.parentNode.removeChild(currentElement); 620 currentElement.parentNode.removeChild(currentElement);
625 621
626 clickHide_deactivate(); 622 clickHide_deactivate();
627 } 623 }
628 break; 624 break;
629 default: 625 default:
630 sendResponse({}); 626 sendResponse({});
631 break; 627 break;
632 } 628 }
633 }); 629 });
634 } 630
631 if (window == window.top)
632 ext.backgroundPage.sendMessage({type: "report-html-page"});
633 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld