| Index: chrome/ext/uninstall.js |
| diff --git a/chrome/ext/uninstall.js b/chrome/ext/uninstall.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b402c7d6b8c2b2a2d5e40106726120d31cc87221 |
| --- /dev/null |
| +++ b/chrome/ext/uninstall.js |
| @@ -0,0 +1,57 @@ |
| +/* |
| + * This file is part of Adblock Plus <https://adblockplus.org/>, |
| + * Copyright (C) 2006-2015 Eyeo GmbH |
| + * |
| + * Adblock Plus is free software: you can redistribute it and/or modify |
| + * it under the terms of the GNU General Public License version 3 as |
| + * published by the Free Software Foundation. |
| + * |
| + * Adblock Plus is distributed in the hope that it will be useful, |
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| + * GNU General Public License for more details. |
| + * |
| + * You should have received a copy of the GNU General Public License |
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| + */ |
| + |
| +(function() |
|
Sebastian Noack
2015/12/09 17:37:31
Once you made this a proper module the IIFE will b
kzar
2015/12/10 14:28:20
Done.
|
| +{ |
| + "use strict"; |
| + |
| + let prefs = require("prefs"); |
|
Sebastian Noack
2015/12/09 17:37:31
Nit: let {Prefs} = require("prefs");
kzar
2015/12/10 14:28:20
Done.
|
| + |
| + function setUninstallURL() |
| + { |
| + let uninstall_url = "https://adblockplus.org/en/uninstall-abp"; |
|
Sebastian Noack
2015/12/09 17:37:31
Please use camel-case consistently.
Sebastian Noack
2015/12/09 17:37:31
Please don't hard code the language part of the UR
kzar
2015/12/10 14:28:20
Done. (Opened issue 3403 for the redirection)
kzar
2015/12/10 14:28:20
Done.
|
| + let module_keys = [ |
| + [require("info"), ["addonName", "addonVersion", "application", |
| + "applicationVersion", "platform", "platformVersion"]], |
| + [require("utils").Utils, ["appLocale"]] |
| + ]; |
| + |
| + let search = []; |
| + for (let module_key of module_keys) |
| + for (let key of module_key[1]) |
| + if (key in module_key[0]) |
|
Sebastian Noack
2015/12/09 17:37:31
I don't see why that check would be necessary.
kzar
2015/12/10 14:28:20
Done.
|
| + search.push(key + "=" + encodeURIComponent(module_key[0][key])); |
| + |
| + let downlCount = prefs.Prefs.notificationdata.downloadCount || 0; |
| + search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); |
|
Sebastian Noack
2015/12/09 17:37:31
You could simplify the loop above if you just hand
kzar
2015/12/10 14:28:20
Done.
|
| + |
| + ext.setUninstallURL(uninstall_url + "?" + search.join("&")); |
| + } |
| + |
| + // The uninstall URL contains the notification download count as a parameter, |
| + // therefore we must wait for preferences to be loaded before generating the |
| + // URL. (But we're not sure if they have already been loaded so we have to do |
| + // it immediately too!) We also need to re-generate the URL each time the |
| + // notification data changes |
| + setUninstallURL(); |
| + prefs.Prefs.onLoaded.addListener(setUninstallURL); |
|
Sebastian Noack
2015/12/09 17:37:31
You should remove the listener once it has been ca
kzar
2015/12/10 14:28:20
Done.
|
| + prefs.Prefs.onChanged.addListener(function(name) |
| + { |
| + if (name == "notificationdata") |
| + setUninstallURL(); |
| + }); |
| +}()); |