Index: chrome/ext/uninstall.js |
diff --git a/chrome/ext/uninstall.js b/chrome/ext/uninstall.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..36ab8e07617b86a5d1f6e544d3b2a3ce70b33231 |
--- /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() |
+{ |
+ "use strict"; |
+ |
+ let prefs = require("prefs"); |
+ |
+ function setUninstallURL() |
+ { |
+ let uninstall_url = "https://adblockplus.org/en/uninstall-abp"; |
+ 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]) |
+ search.push(key + "=" + encodeURIComponent(module_key[0][key])); |
+ |
+ let downlCount = prefs.Prefs.notificationdata.downloadCount || 0; |
+ search.push("notificationDownloadCount=" + encodeURIComponent(downlCount)); |
+ |
+ chrome.runtime.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); |
+ prefs.Prefs.onChanged.addListener(function(name) |
+ { |
+ if (name == "notificationdata") |
+ setUninstallURL(); |
+ }); |
+}()); |