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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 } | 917 } |
918 }, false); | 918 }, false); |
919 request.send(); | 919 request.send(); |
920 } | 920 } |
921 else | 921 else |
922 notifyUser(); | 922 notifyUser(); |
923 }, | 923 }, |
924 | 924 |
925 /** | 925 /** |
926 * Handles clicks inside the browser's content area, will intercept clicks on | 926 * Handles clicks inside the browser's content area, will intercept clicks on |
927 * abp: links. This can be called either with an event object or with the link | 927 * abp: links as well as links to subscribe.adblockplus.org. |
928 * target (if it is the former then link target will be retrieved from event | |
929 * target). | |
930 */ | 928 */ |
931 onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ li
nkTarget) | 929 onBrowserClick: function (/**Window*/ window, /**Event*/ event) |
932 { | 930 { |
933 if (event) | 931 // Ignore right-clicks |
| 932 if (event.button == 2) |
| 933 return; |
| 934 |
| 935 // Search the link associated with the click |
| 936 let link = event.target; |
| 937 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) |
934 { | 938 { |
935 // Ignore right-clicks | 939 link = link.parentNode; |
936 if (event.button == 2) | 940 |
| 941 if (!link) |
937 return; | 942 return; |
938 | |
939 // Search the link associated with the click | |
940 let link = event.target; | |
941 while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement)) | |
942 link = link.parentNode; | |
943 | |
944 if (!link || link.protocol != "abp:") | |
945 return; | |
946 | |
947 // This is our link - make sure the browser doesn't handle it | |
948 event.preventDefault(); | |
949 event.stopPropagation(); | |
950 | |
951 linkTarget = link.href; | |
952 } | 943 } |
953 | 944 |
954 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget); | 945 let queryString = null; |
955 if (!match) | 946 if (link.protocol == "http:" || link.protocol == "https:") |
| 947 { |
| 948 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/") |
| 949 queryString = link.search.substr(1); |
| 950 } |
| 951 else |
| 952 { |
| 953 // Firefox doesn't populate the "search" property for links with |
| 954 // non-standard URL schemes so we need to extract the query string |
| 955 // manually |
| 956 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); |
| 957 if (match) |
| 958 queryString = match[1]; |
| 959 } |
| 960 |
| 961 if (!queryString) |
956 return; | 962 return; |
957 | 963 |
| 964 // This is our link - make sure the browser doesn't handle it |
| 965 event.preventDefault(); |
| 966 event.stopPropagation(); |
| 967 |
958 // Decode URL parameters | 968 // Decode URL parameters |
959 let title = null; | 969 let title = null; |
960 let url = null; | 970 let url = null; |
961 let mainSubscriptionTitle = null; | 971 let mainSubscriptionTitle = null; |
962 let mainSubscriptionURL = null; | 972 let mainSubscriptionURL = null; |
963 for (let param of match[1].split('&')) | 973 for (let param of queryString.split("&")) |
964 { | 974 { |
965 let parts = param.split("=", 2); | 975 let parts = param.split("=", 2); |
966 if (parts.length != 2 || !/\S/.test(parts[1])) | 976 if (parts.length != 2 || !/\S/.test(parts[1])) |
967 continue; | 977 continue; |
968 switch (parts[0]) | 978 switch (parts[0]) |
969 { | 979 { |
970 case "title": | 980 case "title": |
971 title = decodeURIComponent(parts[1]); | 981 title = decodeURIComponent(parts[1]); |
972 break; | 982 break; |
973 case "location": | 983 case "location": |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], | 1989 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], |
1980 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] | 1990 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] |
1981 ]; | 1991 ]; |
1982 | 1992 |
1983 onShutdown.add(function() | 1993 onShutdown.add(function() |
1984 { | 1994 { |
1985 for (let window of UI.applicationWindows) | 1995 for (let window of UI.applicationWindows) |
1986 if (UI.isBottombarOpen(window)) | 1996 if (UI.isBottombarOpen(window)) |
1987 UI.toggleBottombar(window); | 1997 UI.toggleBottombar(window); |
1988 }); | 1998 }); |
OLD | NEW |