Fix updateBadge (grouped sites)
This commit is contained in:
parent
cdbd18bf2a
commit
dcf5d27a9f
@ -273,7 +273,7 @@ const userAgentMobile = "Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ;
|
||||
|
||||
var enabledSites = [];
|
||||
var disabledSites = [];
|
||||
var defaultSites_domains = Object.values(defaultSites);
|
||||
var defaultSites_domains = Object.values(defaultSites).concat(ad_region_domains, au_comm_media_domains, au_news_corp_domains, au_prov_news_domains, nymag_domains);
|
||||
var customSites = {};
|
||||
var customSites_domains = [];
|
||||
|
||||
@ -754,42 +754,40 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
||||
ext_api.tabs.onUpdated.addListener(function (tabId, info, tab) { updateBadge(tab); });
|
||||
ext_api.tabs.onActivated.addListener(function (activeInfo) { ext_api.tabs.get(activeInfo.tabId, updateBadge); });
|
||||
|
||||
function updateBadge (activeTab) {
|
||||
if (!activeTab) { return; }
|
||||
function updateBadge(activeTab) {
|
||||
if (!activeTab)
|
||||
return;
|
||||
let badgeText = '';
|
||||
let color = 'red';
|
||||
let currentUrl = activeTab.url;
|
||||
if (currentUrl) {
|
||||
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
|
||||
let isCustomSite = matchUrlDomain(customSites_domains, currentUrl);
|
||||
if (isSiteEnabled({url: currentUrl})) {
|
||||
badgeText = 'ON';
|
||||
color = 'red';
|
||||
} else if (matchUrlDomain(enabledSites, currentUrl)) {
|
||||
badgeText = 'ON-';
|
||||
color = 'orange';
|
||||
color = 'orange';
|
||||
} else if (matchUrlDomain(disabledSites, currentUrl)) {
|
||||
badgeText = 'OFF';
|
||||
color = 'blue';
|
||||
color = 'blue';
|
||||
}
|
||||
if (!isDefaultSite) {
|
||||
if (isCustomSite) {
|
||||
ext_api.permissions.contains({
|
||||
origins: ["<all_urls>"]
|
||||
}, function (result) {
|
||||
if (!result)
|
||||
badgeText = '';
|
||||
if (color && badgeText)
|
||||
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
||||
ext_api.browserAction.setBadgeText({text: badgeText});
|
||||
});
|
||||
} else {
|
||||
ext_api.browserAction.setBadgeText({text: ''});
|
||||
}
|
||||
let isDefaultSite = matchUrlDomain(defaultSites_domains, currentUrl);
|
||||
let isCustomSite = matchUrlDomain(customSites_domains, currentUrl);
|
||||
if (!isDefaultSite && isCustomSite) {
|
||||
ext_api.permissions.contains({
|
||||
origins: ["<all_urls>"]
|
||||
}, function (result) {
|
||||
if (!result)
|
||||
badgeText = '';
|
||||
if (color && badgeText)
|
||||
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
||||
ext_api.browserAction.setBadgeText({text: badgeText});
|
||||
});
|
||||
} else {
|
||||
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
||||
if (color && badgeText)
|
||||
ext_api.browserAction.setBadgeBackgroundColor({color: color});
|
||||
ext_api.browserAction.setBadgeText({text: badgeText});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
Changelog Bypass Paywalls Clean - Chrome
|
||||
|
||||
Post-release
|
||||
Fix updateBadge (grouped sites)
|
||||
|
||||
* v1.9.3.0 (2020-11-01)
|
||||
Add Deutsche Wirtschafts Nachrichten
|
||||
|
Loading…
x
Reference in New Issue
Block a user