Index: desktop-options.js |
=================================================================== |
--- a/desktop-options.js |
+++ b/desktop-options.js |
@@ -22,17 +22,17 @@ |
{ |
let subscriptionsMap = Object.create(null); |
let filtersMap = Object.create(null); |
let collections = Object.create(null); |
let acceptableAdsUrl = null; |
let acceptableAdsPrivacyUrl = null; |
let isCustomFiltersLoaded = false; |
- let {getMessage} = chrome.i18n; |
+ let {getMessage} = browser.i18n; |
let customFilters = []; |
let filterErrors = new Map([ |
["synchronize_invalid_url", |
"options_filterList_lastDownload_invalidURL"], |
["synchronize_connection_error", |
"options_filterList_lastDownload_connectionError"], |
["synchronize_invalid_data", |
"options_filterList_lastDownload_invalidData"], |
@@ -538,17 +538,17 @@ |
element = element.parentElement; |
} |
return null; |
} |
function sendMessageHandleErrors(message, onSuccess) |
{ |
- chrome.runtime.sendMessage(message, (errors) => |
+ browser.runtime.sendMessage(message, (errors) => |
{ |
if (errors.length > 0) |
alert(errors.join("\n")); |
else if (onSuccess) |
onSuccess(); |
}); |
} |
@@ -580,21 +580,21 @@ |
break; |
case "change-language-subscription": |
for (let key in subscriptionsMap) |
{ |
let subscription = subscriptionsMap[key]; |
let subscriptionType = subscription.recommended; |
if (subscriptionType == "ads" && subscription.disabled == false) |
{ |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.remove", |
url: subscription.url |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.add", |
url: findParentData(element, "access", false) |
}); |
break; |
} |
} |
break; |
case "close-dialog": |
@@ -622,23 +622,23 @@ |
break; |
} |
case "open-dialog": { |
let dialog = findParentData(element, "dialog", false); |
openDialog(dialog); |
break; |
} |
case "remove-filter": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "filters.remove", |
text: findParentData(element, "access", false) |
}); |
break; |
case "remove-subscription": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.remove", |
url: findParentData(element, "access", false) |
}); |
break; |
case "save-custom-filters": |
sendMessageHandleErrors({ |
type: "filters.importRaw", |
text: E("custom-filters-raw").value, |
@@ -649,61 +649,61 @@ |
setCustomFiltersView("read"); |
}); |
break; |
case "show-more-filters-section": |
E("more-filters").setAttribute("aria-hidden", false); |
break; |
case "switch-acceptable-ads": |
let value = element.value || element.dataset.value; |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: value == "privacy" ? "subscriptions.add" : |
"subscriptions.remove", |
url: acceptableAdsPrivacyUrl |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", |
url: acceptableAdsUrl |
}); |
break; |
case "switch-tab": |
switchTab(element.getAttribute("href").substr(1)); |
break; |
case "toggle-disable-subscription": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.toggle", |
keepInstalled: true, |
url: findParentData(element, "access", false) |
}); |
break; |
case "toggle-pref": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "prefs.toggle", |
key: findParentData(element, "pref", false) |
}); |
break; |
case "toggle-remove-subscription": |
let subscriptionUrl = findParentData(element, "access", false); |
if (element.getAttribute("aria-checked") == "true") |
{ |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.remove", |
url: subscriptionUrl |
}); |
} |
else |
addEnableSubscription(subscriptionUrl); |
break; |
case "update-all-subscriptions": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.update" |
}); |
break; |
case "update-subscription": |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.update", |
url: findParentData(element, "access", false) |
}); |
break; |
case "validate-import-subscription": |
let form = findParentData(element, "validation", true); |
if (!form) |
return; |
@@ -855,17 +855,17 @@ |
} |
} |
function onDOMLoaded() |
{ |
populateLists(); |
// Initialize navigation sidebar |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "app.get", |
what: "addonVersion" |
}, |
(addonVersion) => |
{ |
E("abp-version").textContent = getMessage("options_dialog_about_version", |
[addonVersion]); |
}); |
@@ -904,17 +904,17 @@ |
}); |
for (let key of customize) |
{ |
getPref(key, (value) => |
{ |
onPrefMessage(key, value, true); |
}); |
} |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "app.get", |
what: "features" |
}, |
(features) => |
{ |
hidePref("show_devtools_panel", !features.devToolsPanel); |
}); |
@@ -1060,54 +1060,54 @@ |
subscriptionsMap = Object.create(null); |
filtersMap = Object.create(null); |
// Empty collections and lists |
for (let property in collections) |
collections[property].clearAll(); |
setCustomFiltersView("empty"); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.get", |
special: true |
}, |
(subscriptions) => |
{ |
// Load filters |
for (let subscription of subscriptions) |
{ |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "filters.get", |
subscriptionUrl: subscription.url |
}, |
(filters) => |
{ |
loadCustomFilters(filters); |
}); |
} |
}); |
loadRecommendations(); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "prefs.get", |
key: "subscriptions_exceptionsurl" |
}, |
(url) => |
{ |
acceptableAdsUrl = url; |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "prefs.get", |
key: "subscriptions_exceptionsurl_privacy" |
}, |
(urlPrivacy) => |
{ |
acceptableAdsPrivacyUrl = urlPrivacy; |
// Load user subscriptions |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.get", |
downloadable: true |
}, |
(subscriptions) => |
{ |
for (let subscription of subscriptions) |
onSubscriptionMessage("added", subscription); |
@@ -1155,17 +1155,17 @@ |
type: messageType, |
url |
}; |
if (title) |
message.title = title; |
if (homepage) |
message.homepage = homepage; |
- chrome.runtime.sendMessage(message); |
+ browser.runtime.sendMessage(message); |
} |
function onFilterMessage(action, filter) |
{ |
switch (action) |
{ |
case "added": |
filter[timestampUI] = Date.now(); |
@@ -1266,17 +1266,17 @@ |
checkPref((isActive) => |
{ |
if (!isActive) |
{ |
hidePref(key, !isActive); |
return; |
} |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "prefs.get", |
key |
}, callback); |
}); |
} |
getPref.checkNone = function(callback) |
{ |
@@ -1360,30 +1360,30 @@ |
onPrefMessage(message.action, message.args[0], false); |
break; |
case "subscriptions.respond": |
onSubscriptionMessage(message.action, message.args[0]); |
break; |
} |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "app.listen", |
filter: ["addSubscription", "focusSection"] |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "filters.listen", |
filter: ["added", "loaded", "removed"] |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "prefs.listen", |
filter: ["notifications_ignoredcategories", "notifications_showui", |
"show_devtools_panel", "shouldShowBlockElementMenu"] |
}); |
- chrome.runtime.sendMessage({ |
+ browser.runtime.sendMessage({ |
type: "subscriptions.listen", |
filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
"title", "downloadStatus", "downloading"] |
}); |
window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
window.addEventListener("hashchange", onHashChange, false); |
} |