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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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:") | |
kzar
2015/03/25 14:09:29
(Do we even need to support http? I guess we will
Sebastian Noack
2015/03/25 14:21:04
We probably will. But others linking to our websit
| |
622 { | |
623 if (link.host != "subscribe.adblockplus.org" || link.pathname != "/") | |
624 return; | |
625 } | |
626 else if (!/^abp:\/*subscribe\/*\?(.*)/i.test(link.href)) | |
Thomas Greiner
2015/03/25 15:05:36
The `(.*)` at the end of the regular expression is
Wladimir Palant
2015/03/25 15:07:17
Nit: Please remove the parentheses in this regexp
Sebastian Noack
2015/03/25 15:23:26
Done.
| |
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("&"); |
Wladimir Palant
2015/03/25 15:07:17
Note that this change will make the approach incon
Sebastian Noack
2015/03/25 15:23:26
Well, the alternative would be to make things inco
| |
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 Loading... | |
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 } |
OLD | NEW |