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

Side by Side Diff: include.postload.js

Issue 5246523029848064: Issue 2212 - Implement http://subscribe.adblockplus.org/?... subscription links (Closed)
Patch Set: Removed unneeded regexp group Created March 25, 2015, 3:23 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 <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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 }, true); 603 }, true);
604 604
605 document.addEventListener("click", function(event) 605 document.addEventListener("click", function(event)
606 { 606 {
607 // Ignore right-clicks 607 // Ignore right-clicks
608 if (event.button == 2) 608 if (event.button == 2)
609 return; 609 return;
610 610
611 // Search the link associated with the click 611 // Search the link associated with the click
612 var link = event.target; 612 var link = event.target;
613 while (link && !(link instanceof HTMLAnchorElement)) 613 while (!(link instanceof HTMLAnchorElement))
614 {
614 link = link.parentNode; 615 link = link.parentNode;
615 616
616 if (!link || link.protocol != "abp:") 617 if (!link)
618 return;
619 }
620
621 if (link.protocol == "http:" || link.protocol == "https:")
622 {
623 if (link.host != "subscribe.adblockplus.org" || link.pathname != "/")
624 return;
625 }
626 else if (!/^abp:\/*subscribe\/*\?/i.test(link.href))
617 return; 627 return;
618 628
619 // This is our link - make sure the browser doesn't handle it 629 // This is our link - make sure the browser doesn't handle it
620 event.preventDefault(); 630 event.preventDefault();
621 event.stopPropagation(); 631 event.stopPropagation();
622 632
623 var linkTarget = link.href;
624 if (!/^abp:\/*subscribe\/*\?(.*)/i.test(linkTarget)) /**/
625 return;
626
627 // Decode URL parameters 633 // Decode URL parameters
628 var params = RegExp.$1.split("&"); 634 var params = link.search.substr(1).split("&");
629 var title = null; 635 var title = null;
630 var url = null; 636 var url = null;
631 for (var i = 0; i < params.length; i++) 637 for (var i = 0; i < params.length; i++)
632 { 638 {
633 var parts = params[i].split("=", 2); 639 var parts = params[i].split("=", 2);
634 if (parts.length != 2 || !/\S/.test(parts[1])) 640 if (parts.length != 2 || !/\S/.test(parts[1]))
635 continue; 641 continue;
636 switch (parts[0]) 642 switch (parts[0])
637 { 643 {
638 case "title": 644 case "title":
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 lastRightClickEventValid = false; 736 lastRightClickEventValid = false;
731 else 737 else
732 lastRightClickEvent = null; 738 lastRightClickEvent = null;
733 break; 739 break;
734 } 740 }
735 }); 741 });
736 742
737 if (window == window.top) 743 if (window == window.top)
738 ext.backgroundPage.sendMessage({type: "report-html-page"}); 744 ext.backgroundPage.sendMessage({type: "report-html-page"});
739 } 745 }
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