Fixed: Icons disabled for mobile devices and browsers without support for extension icons

This commit is contained in:
nobody 2020-09-27 11:46:32 +02:00
parent cf27bde0c8
commit c75e98b9a7
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 29 additions and 25 deletions

View File

@ -56,10 +56,8 @@ wrappers.setBadgeTextColor = function (details) {
wrappers.setIcon = function (details, type) {
if (chrome.browserAction.setIcon) {
details.path = IconType[details.path][type];
} else {
details.path = IconType['Default'][type];
chrome.browserAction.setIcon(details);
}
chrome.browserAction.setIcon(details);
};
storageManager.type.get([Setting.BADGE_COLOR, Setting.BADGE_TEXT_COLOR], function (items) {

View File

@ -47,6 +47,7 @@ options._renderContents = function () {
if (!chrome.browserAction.setIcon) {
document.getElementById('icon-style-div').style.display = 'none';
options._platformSupportIcons = false;
}
options._renderInfoPanel();
document.getElementById('label-version').textContent = helpers.formatVersion(chrome.runtime.getManifest().version);
@ -108,28 +109,29 @@ options._renderOptionsPanel = function () {
document.getElementById('storage-type-sync').checked = true;
}
if (options._optionValues.selectedIcon === 'Default') {
document.getElementById('icon-default').checked = true;
} else if (options._optionValues.selectedIcon === 'Grey') {
document.getElementById('icon-grey').checked = true;
} else if (options._optionValues.selectedIcon === 'Light') {
document.getElementById('icon-light').checked = true;
if (options._platformSupportIcons) {
if (options._optionValues.selectedIcon === 'Default') {
document.getElementById('icon-default').checked = true;
} else if (options._optionValues.selectedIcon === 'Grey') {
document.getElementById('icon-grey').checked = true;
} else if (options._optionValues.selectedIcon === 'Light') {
document.getElementById('icon-light').checked = true;
}
url = chrome.runtime.getURL('icons/action/' + options._optionValues.selectedIcon.toLowerCase() + '/icon38-default.png');
document.getElementById('icon-badge-preview').src = url;
bgColor = options._optionValues.badgeColor || '#4A826C';
txtColor = options._optionValues.badgeTextColor || '#FFFFFF';
document.getElementById('counter-preview-badge').style.backgroundColor = bgColor;
document.getElementById('pre-badged-background-color').style.backgroundColor = bgColor;
document.getElementById('badged-background-color').value = bgColor;
document.getElementById('counter-preview-badge').style.color = txtColor;
document.getElementById('pre-badged-text-color').style.backgroundColor = txtColor;
document.getElementById('badged-text-color').value = txtColor;
}
url = chrome.runtime.getURL('icons/action/' + options._optionValues.selectedIcon.toLowerCase() + '/icon38-default.png');
document.getElementById('icon-badge-preview').src = url;
bgColor = options._optionValues.badgeColor || '#4A826C';
txtColor = options._optionValues.badgeTextColor || '#FFFFFF';
document.getElementById('counter-preview-badge').style.backgroundColor = bgColor;
document.getElementById('pre-badged-background-color').style.backgroundColor = bgColor;
document.getElementById('badged-background-color').value = bgColor;
document.getElementById('counter-preview-badge').style.color = txtColor;
document.getElementById('pre-badged-text-color').style.backgroundColor = txtColor;
document.getElementById('badged-text-color').value = txtColor;
document.getElementById('last-mapping-update').textContent += ' ' + lastMappingUpdate;
document.getElementById('negate-html-filter-list-warning').addEventListener('click', function () { options._onLinkClick(Links.CODEBERG_HTML_FILTER); });
document.getElementById('link-welcome-page').addEventListener('click', function () { options._onLinkClick(Links.WELCOME); });
@ -151,8 +153,10 @@ options._renderOptionsPanel = function () {
document.getElementById('import-data').addEventListener('click', storageManager.startImportFilePicker);
document.getElementById('import-file-picker').addEventListener('change', storageManager.handleImportFilePicker);
document.getElementById('badged-background-color').addEventListener('keyup', options._onChangedHexColor);
document.getElementById('badged-text-color').addEventListener('keyup', options._onChangedHexColor);
if (options._platformSupportIcons) {
document.getElementById('badged-background-color').addEventListener('keyup', options._onChangedHexColor);
document.getElementById('badged-text-color').addEventListener('keyup', options._onChangedHexColor);
}
document.getElementById('restore-background-color').addEventListener('click', options._setDefaultColor);
document.getElementById('restore-text-color').addEventListener('click', options._setDefaultColor);
@ -554,6 +558,7 @@ options._internalStatistics = false;
options._storageType = 'local';
options._listOfFrameworks = {};
options._listOfCDNs = {};
options._platformSupportIcons = true;
document.addEventListener('DOMContentLoaded', options._onDocumentLoaded);

View File

@ -26,6 +26,7 @@
</div>
<ul>
<li>Updated: Internal module "Color Picker" v2.1.2 -> v2.1.3</li>
<li>Fixed: Icons disabled for mobile devices and browsers without support for extension icons</li>
</ul>
<div id="generator-section">
<div class="topic-label">