Fix updateBadge (custom sites disabled)

This commit is contained in:
magnolia1234 2020-11-01 17:46:29 +01:00
parent fdf269880c
commit b5f813b0ca
3 changed files with 26 additions and 4 deletions

View file

@ -731,7 +731,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
currentWindow: true
}, function (tabs) {
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
if (isSiteEnabled({url: tabs[0].url}) || medium_custom_domain) {
if (isSiteEnabled({url: tabs[0].url})) {
ext_api.tabs.executeScript({
file: 'contentScript.js',
runAt: 'document_start'
@ -761,6 +761,7 @@ function updateBadge (activeTab) {
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';
@ -771,11 +772,28 @@ function updateBadge (activeTab) {
badgeText = 'OFF';
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: ''});
}
} else {
ext_api.browserAction.setBadgeBackgroundColor({color: color});
ext_api.browserAction.setBadgeText({text: badgeText});
}
}
ext_api.browserAction.setBadgeBackgroundColor({color: color});
ext_api.browserAction.setBadgeText({text: badgeText});
}
function site_switch() {
ext_api.tabs.query({
active: true,

View file

@ -6,6 +6,7 @@ Add Deutsche Wirtschafts Nachrichten
Add WirtschaftsWoche (Germany)
Fix-update Quartz (newsletter)
Fix-update Sueddeutsche Zeitung (+ magazine)
Fix updateBadge (custom sites disabled)
Icon for dark/incognito mode (Chrome)
Save options to storage.local (quota exceeded)

View file

@ -18,7 +18,10 @@ fetch(manifest_new)
versionString_new.appendChild(document.createTextNode(' * '));
var anchorEl = document.createElement('a');
anchorEl.text = 'New release v' + version_new;
anchorEl.href = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/downloads';
if (manifestData.applications.gecko.id.includes('magnolia'))
anchorEl.href = 'https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/downloads';
else
anchorEl.href = 'https://addons.mozilla.org/en-US/firefox/addon/bypass-paywalls-clean';
anchorEl.target = '_blank';
versionString_new.appendChild(anchorEl);
if (manifestData.name.includes('(lp')) {