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. |
899 * target (if it is the former then link target will be retrieved from event | |
900 * target). | |
901 */ | 899 */ |
902 onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ li nkTarget) | 900 onBrowserClick: function (/**Window*/ window, /**Event*/ event) |
Wladimir Palant
2015/07/20 11:23:10
It seems that currently we will always get an even
| |
903 { | 901 { |
904 if (event) | 902 // Ignore right-clicks |
903 if (event.button == 2) | |
904 return; | |
905 | |
906 // Search the link associated with the click | |
907 let link = event.target; | |
908 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) | |
905 { | 909 { |
906 // Ignore right-clicks | 910 link = link.parentNode; |
907 if (event.button == 2) | 911 |
912 if (!link) | |
908 return; | 913 return; |
909 | |
910 // Search the link associated with the click | |
911 let link = event.target; | |
912 while (link && !(link instanceof Ci.nsIDOMHTMLAnchorElement)) | |
913 link = link.parentNode; | |
914 | |
915 if (!link || link.protocol != "abp:") | |
916 return; | |
917 | |
918 // This is our link - make sure the browser doesn't handle it | |
919 event.preventDefault(); | |
920 event.stopPropagation(); | |
921 | |
922 linkTarget = link.href; | |
923 } | 914 } |
924 | 915 |
925 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(linkTarget); | 916 let queryString = null; |
926 if (!match) | 917 if (link.protocol == "http:" || link.protocol == "https:") |
918 { | |
919 if (link.host == "subscribe.adblockplus.org" || link.pathname == "/") | |
Wladimir Palant
2015/07/20 11:23:10
Shouldn't this be && rather than ||?
Thomas Greiner
2015/07/20 14:00:53
Done.
| |
920 queryString = link.search.substr(1); | |
921 } | |
922 else | |
923 { | |
924 // Firefox doesn't populate the "search" property for links with | |
925 // non-standard URL schemes so we need to extract the query string | |
926 // manually | |
927 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); | |
928 if (match) | |
929 queryString = match[1]; | |
930 } | |
931 | |
932 if (!queryString) | |
927 return; | 933 return; |
928 | 934 |
935 // This is our link - make sure the browser doesn't handle it | |
936 event.preventDefault(); | |
937 event.stopPropagation(); | |
938 | |
929 // Decode URL parameters | 939 // Decode URL parameters |
930 let title = null; | 940 let title = null; |
931 let url = null; | 941 let url = null; |
932 let mainSubscriptionTitle = null; | 942 let mainSubscriptionTitle = null; |
933 let mainSubscriptionURL = null; | 943 let mainSubscriptionURL = null; |
934 for (let param of match[1].split('&')) | 944 for (let param of queryString.split("&")) |
935 { | 945 { |
936 let parts = param.split("=", 2); | 946 let parts = param.split("=", 2); |
937 if (parts.length != 2 || !/\S/.test(parts[1])) | 947 if (parts.length != 2 || !/\S/.test(parts[1])) |
938 continue; | 948 continue; |
939 switch (parts[0]) | 949 switch (parts[0]) |
940 { | 950 { |
941 case "title": | 951 case "title": |
942 title = decodeURIComponent(parts[1]); | 952 title = decodeURIComponent(parts[1]); |
943 break; | 953 break; |
944 case "location": | 954 case "location": |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1963 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1973 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1964 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1974 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1965 ]; | 1975 ]; |
1966 | 1976 |
1967 onShutdown.add(function() | 1977 onShutdown.add(function() |
1968 { | 1978 { |
1969 for (let window in UI.applicationWindows) | 1979 for (let window in UI.applicationWindows) |
1970 if (UI.isBottombarOpen(window)) | 1980 if (UI.isBottombarOpen(window)) |
1971 UI.toggleBottombar(window); | 1981 UI.toggleBottombar(window); |
1972 }); | 1982 }); |
OLD | NEW |