| 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 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 888 } | 888 } |
| 889 }, false); | 889 }, false); |
| 890 request.send(); | 890 request.send(); |
| 891 } | 891 } |
| 892 else | 892 else |
| 893 notifyUser(); | 893 notifyUser(); |
| 894 }, | 894 }, |
| 895 | 895 |
| 896 /** | 896 /** |
| 897 * Handles clicks inside the browser's content area, will intercept clicks on | 897 * Handles clicks inside the browser's content area, will intercept clicks on |
| 898 * abp: links. This can be called either with an event object or with the link | 898 * abp: links as well as links to subscribe.adblockplus.org. This can be calle d |
| 899 * target (if it is the former then link target will be retrieved from event | 899 * either with an event object or with the link target (if it is the former th en |
| 900 * target). | 900 * link target will be retrieved from event target). |
| 901 */ | 901 */ |
| 902 onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ li nkTarget) | 902 onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ li nkTarget) |
| 903 { | 903 { |
| 904 if (event) | 904 if (event) |
| 905 { | 905 { |
| 906 // Ignore right-clicks | 906 // Ignore right-clicks |
| 907 if (event.button == 2) | 907 if (event.button == 2) |
| 908 return; | 908 return; |
| 909 | 909 |
| 910 // Search the link associated with the click | 910 // Search the link associated with the click |
| 911 let link = event.target; | 911 let link = event.target; |
| 912 while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement)) | 912 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) |
| 913 { | |
| 913 link = link.parentNode; | 914 link = link.parentNode; |
| 914 | 915 |
| 915 if (!link || link.protocol != "abp:") | 916 if (!link) |
| 916 return; | 917 return; |
| 918 } | |
| 919 linkTarget = link.href; | |
| 920 } | |
| 917 | 921 |
| 922 let match = /^(?:abp:\/*subscribe|https?:\/*subscribe\.adblockplus\.org)\/*\ ?(.*)/i.exec(linkTarget); | |
|
Sebastian Noack
2015/04/01 12:29:49
I think we should use DOM API's (i.e. the anchor e
Thomas Greiner
2015/04/01 12:41:15
It's a different situation than on Chrome since we
Sebastian Noack
2015/04/01 12:44:20
I'm not sure what you mean. Since you already use
Thomas Greiner
2015/04/01 12:51:30
There are two ways to get a link target here. One
| |
| 923 if (!match) | |
| 924 return; | |
| 925 | |
| 926 if (event) | |
| 927 { | |
| 918 // This is our link - make sure the browser doesn't handle it | 928 // This is our link - make sure the browser doesn't handle it |
| 919 event.preventDefault(); | 929 event.preventDefault(); |
| 920 event.stopPropagation(); | 930 event.stopPropagation(); |
| 921 | |
| 922 linkTarget = link.href; | |
| 923 } | 931 } |
| 924 | 932 |
| 925 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget); | |
| 926 if (!match) | |
| 927 return; | |
| 928 | |
| 929 // Decode URL parameters | 933 // Decode URL parameters |
| 930 let title = null; | 934 let title = null; |
| 931 let url = null; | 935 let url = null; |
| 932 let mainSubscriptionTitle = null; | 936 let mainSubscriptionTitle = null; |
| 933 let mainSubscriptionURL = null; | 937 let mainSubscriptionURL = null; |
| 934 for (let param of match[1].split('&')) | 938 for (let param of match[1].split("&")) |
| 935 { | 939 { |
| 936 let parts = param.split("=", 2); | 940 let parts = param.split("=", 2); |
| 937 if (parts.length != 2 || !/\S/.test(parts[1])) | 941 if (parts.length != 2 || !/\S/.test(parts[1])) |
| 938 continue; | 942 continue; |
| 939 switch (parts[0]) | 943 switch (parts[0]) |
| 940 { | 944 { |
| 941 case "title": | 945 case "title": |
| 942 title = decodeURIComponent(parts[1]); | 946 title = decodeURIComponent(parts[1]); |
| 943 break; | 947 break; |
| 944 case "location": | 948 case "location": |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1963 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1967 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1964 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1968 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1965 ]; | 1969 ]; |
| 1966 | 1970 |
| 1967 onShutdown.add(function() | 1971 onShutdown.add(function() |
| 1968 { | 1972 { |
| 1969 for (let window in UI.applicationWindows) | 1973 for (let window in UI.applicationWindows) |
| 1970 if (UI.isBottombarOpen(window)) | 1974 if (UI.isBottombarOpen(window)) |
| 1971 UI.toggleBottombar(window); | 1975 UI.toggleBottombar(window); |
| 1972 }); | 1976 }); |
| OLD | NEW |