| LEFT | RIGHT |
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| (...skipping 18 matching lines...) Expand all Loading... |
| 32 // Search the link associated with the click | 32 // Search the link associated with the click |
| 33 let link = event.target; | 33 let link = event.target; |
| 34 while (!(link instanceof HTMLAnchorElement)) | 34 while (!(link instanceof HTMLAnchorElement)) |
| 35 { | 35 { |
| 36 link = link.parentNode; | 36 link = link.parentNode; |
| 37 | 37 |
| 38 if (!link) | 38 if (!link) |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 let queryString = null; |
| 42 if (link.protocol == "http:" || link.protocol == "https:") | 43 if (link.protocol == "http:" || link.protocol == "https:") |
| 43 { | 44 { |
| 44 if (link.host != "subscribe.adblockplus.org" || link.pathname != "/") | 45 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/") |
| 45 return; | 46 queryString = link.search.substr(1); |
| 46 } | 47 } |
| 47 else if (!/^abp:\/*subscribe\/*\?/i.test(link.href)) | 48 else |
| 48 { | 49 { |
| 50 // Firefox 51 doesn't seem to populate the "search" property for |
| 51 // links with non-standard URL schemes so we need to extract the query |
| 52 // string manually. |
| 53 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); |
| 54 if (match) |
| 55 queryString = match[1]; |
| 56 } |
| 57 |
| 58 if (!queryString) |
| 49 return; | 59 return; |
| 50 } | |
| 51 | 60 |
| 52 // This is our link - make sure the browser doesn't handle it | 61 // This is our link - make sure the browser doesn't handle it |
| 53 event.preventDefault(); | 62 event.preventDefault(); |
| 54 event.stopPropagation(); | 63 event.stopPropagation(); |
| 55 | 64 |
| 56 // Decode URL parameters | 65 // Decode URL parameters |
| 57 let title = null; | 66 let title = null; |
| 58 let url = null; | 67 let url = null; |
| 59 for (let param of link.search.substr(1).split("&")) | 68 for (let param of queryString.split("&")) |
| 60 { | 69 { |
| 61 let parts = param.split("=", 2); | 70 let parts = param.split("=", 2); |
| 62 if (parts.length != 2 || !/\S/.test(parts[1])) | 71 if (parts.length != 2 || !/\S/.test(parts[1])) |
| 63 continue; | 72 continue; |
| 64 switch (parts[0]) | 73 switch (parts[0]) |
| 65 { | 74 { |
| 66 case "title": | 75 case "title": |
| 67 title = decodeURIComponent(parts[1]); | 76 title = decodeURIComponent(parts[1]); |
| 68 break; | 77 break; |
| 69 case "location": | 78 case "location": |
| (...skipping 15 matching lines...) Expand all Loading... |
| 85 return; | 94 return; |
| 86 | 95 |
| 87 ext.backgroundPage.sendMessage({ | 96 ext.backgroundPage.sendMessage({ |
| 88 type: "subscriptions.add", | 97 type: "subscriptions.add", |
| 89 title, | 98 title, |
| 90 url, | 99 url, |
| 91 confirm: true | 100 confirm: true |
| 92 }); | 101 }); |
| 93 }, true); | 102 }, true); |
| 94 } | 103 } |
| LEFT | RIGHT |