Index: desktop-options.js |
=================================================================== |
--- a/desktop-options.js |
+++ b/desktop-options.js |
@@ -538,17 +538,17 @@ |
element = element.parentElement; |
} |
return null; |
} |
function sendMessageHandleErrors(message, onSuccess) |
{ |
- ext.backgroundPage.sendMessage(message, (errors) => |
+ chrome.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) |
{ |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.remove", |
url: subscription.url |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.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": |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "filters.remove", |
text: findParentData(element, "access", false) |
}); |
break; |
case "remove-subscription": |
- ext.backgroundPage.sendMessage({ |
+ chrome.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; |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: value == "privacy" ? "subscriptions.add" : |
"subscriptions.remove", |
url: acceptableAdsPrivacyUrl |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.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": |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.toggle", |
keepInstalled: true, |
url: findParentData(element, "access", false) |
}); |
break; |
case "toggle-pref": |
- ext.backgroundPage.sendMessage({ |
+ chrome.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") |
{ |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.remove", |
url: subscriptionUrl |
}); |
} |
else |
addEnableSubscription(subscriptionUrl); |
break; |
case "update-all-subscriptions": |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.update" |
}); |
break; |
case "update-subscription": |
- ext.backgroundPage.sendMessage({ |
+ chrome.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 |
- ext.backgroundPage.sendMessage({ |
+ chrome.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); |
}); |
} |
- ext.backgroundPage.sendMessage({ |
+ chrome.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"); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.get", |
special: true |
}, |
(subscriptions) => |
{ |
// Load filters |
for (let subscription of subscriptions) |
{ |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "filters.get", |
subscriptionUrl: subscription.url |
}, |
(filters) => |
{ |
loadCustomFilters(filters); |
}); |
} |
}); |
loadRecommendations(); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "prefs.get", |
key: "subscriptions_exceptionsurl" |
}, |
(url) => |
{ |
acceptableAdsUrl = url; |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "prefs.get", |
key: "subscriptions_exceptionsurl_privacy" |
}, |
(urlPrivacy) => |
{ |
acceptableAdsPrivacyUrl = urlPrivacy; |
// Load user subscriptions |
- ext.backgroundPage.sendMessage({ |
+ chrome.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; |
- ext.backgroundPage.sendMessage(message); |
+ chrome.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; |
} |
- ext.backgroundPage.sendMessage({ |
+ chrome.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; |
} |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "app.listen", |
filter: ["addSubscription", "focusSection"] |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "filters.listen", |
filter: ["added", "loaded", "removed"] |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "prefs.listen", |
filter: ["notifications_ignoredcategories", "notifications_showui", |
"show_devtools_panel", "shouldShowBlockElementMenu"] |
}); |
- ext.backgroundPage.sendMessage({ |
+ chrome.runtime.sendMessage({ |
type: "subscriptions.listen", |
filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
"title", "downloadStatus", "downloading"] |
}); |
window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
window.addEventListener("hashchange", onHashChange, false); |
} |