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 |
Wladimir Palant
2015/04/01 17:49:31
Nit: Please stick to the 80 characters line limit.
Thomas Greiner
2015/04/02 14:26:43
Done. I also added a preference to my editor to no
| |
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) |
Wladimir Palant
2015/04/01 17:49:31
It seems that the linkTarget parameter is no longe
Thomas Greiner
2015/04/02 14:26:43
Done.
| |
903 { | 903 { |
904 let link = null; | |
905 if (linkTarget) | |
906 { | |
907 try | |
908 { | |
909 link = new URL(linkTarget); | |
910 } | |
911 catch(ex) | |
912 { | |
913 // Don't handle links with invalid URLs | |
914 return; | |
915 } | |
916 } | |
917 | |
904 if (event) | 918 if (event) |
905 { | 919 { |
906 // Ignore right-clicks | 920 // Ignore right-clicks |
907 if (event.button == 2) | 921 if (event.button == 2) |
908 return; | 922 return; |
909 | 923 |
910 // Search the link associated with the click | 924 // Search the link associated with the click |
911 let link = event.target; | 925 link = event.target; |
912 while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement)) | 926 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) |
927 { | |
913 link = link.parentNode; | 928 link = link.parentNode; |
914 | 929 |
915 if (!link || link.protocol != "abp:") | 930 if (!link) |
916 return; | 931 return; |
932 } | |
933 } | |
917 | 934 |
935 let queryString = null; | |
936 if (link.protocol == "http:" || link.protocol == "https:") | |
937 { | |
938 if (link.host == "subscribe.adblockplus.org" || link.pathname == "/") | |
939 queryString = link.search.substr(1); | |
940 } | |
941 else | |
942 { | |
943 // Firefox doesn't populate the "search" property for links with | |
944 // non-standard URL schemes so we need to extract the query string | |
945 // manually | |
946 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); | |
947 if (match) | |
948 queryString = match[1]; | |
949 } | |
950 | |
951 if (!queryString) | |
952 return; | |
953 | |
954 if (event) | |
955 { | |
918 // This is our link - make sure the browser doesn't handle it | 956 // This is our link - make sure the browser doesn't handle it |
919 event.preventDefault(); | 957 event.preventDefault(); |
920 event.stopPropagation(); | 958 event.stopPropagation(); |
921 | |
922 linkTarget = link.href; | |
923 } | 959 } |
924 | 960 |
925 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget); | |
926 if (!match) | |
927 return; | |
928 | |
929 // Decode URL parameters | 961 // Decode URL parameters |
930 let title = null; | 962 let title = null; |
931 let url = null; | 963 let url = null; |
932 let mainSubscriptionTitle = null; | 964 let mainSubscriptionTitle = null; |
933 let mainSubscriptionURL = null; | 965 let mainSubscriptionURL = null; |
934 for (let param of match[1].split('&')) | 966 for (let param of queryString.split("&")) |
935 { | 967 { |
936 let parts = param.split("=", 2); | 968 let parts = param.split("=", 2); |
937 if (parts.length != 2 || !/\S/.test(parts[1])) | 969 if (parts.length != 2 || !/\S/.test(parts[1])) |
938 continue; | 970 continue; |
939 switch (parts[0]) | 971 switch (parts[0]) |
940 { | 972 { |
941 case "title": | 973 case "title": |
942 title = decodeURIComponent(parts[1]); | 974 title = decodeURIComponent(parts[1]); |
943 break; | 975 break; |
944 case "location": | 976 case "location": |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1963 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1995 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1964 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1996 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1965 ]; | 1997 ]; |
1966 | 1998 |
1967 onShutdown.add(function() | 1999 onShutdown.add(function() |
1968 { | 2000 { |
1969 for (let window in UI.applicationWindows) | 2001 for (let window in UI.applicationWindows) |
1970 if (UI.isBottombarOpen(window)) | 2002 if (UI.isBottombarOpen(window)) |
1971 UI.toggleBottombar(window); | 2003 UI.toggleBottombar(window); |
1972 }); | 2004 }); |
OLD | NEW |