Add an option to display Badge text on the icon in the toolbar #101

This commit is contained in:
proxy.zeroomega 2025-02-15 14:01:26 +08:00
parent fa756d806a
commit fca91b8b36
6 changed files with 20 additions and 0 deletions

View File

@ -266,6 +266,9 @@ msgstr "Allow inspecting proxy used for page elements via context menu."
msgid "options_addConditionsToBottom" msgid "options_addConditionsToBottom"
msgstr "Put new conditions added using the popup to the bottom of the list." msgstr "Put new conditions added using the popup to the bottom of the list."
msgid "options_showResultProfileOnActionBadgeText"
msgstr "show the result profile's name on the action badge text."
msgid "options_group_keyboardShortcut" msgid "options_group_keyboardShortcut"
msgstr "Keyboard Shortcut" msgstr "Keyboard Shortcut"

View File

@ -248,6 +248,9 @@ msgstr "右键菜单中,可检查网页元素所使用的代理。"
msgid "options_addConditionsToBottom" msgid "options_addConditionsToBottom"
msgstr "把以弹出菜单方式创建的规则添加到列表末尾。" msgstr "把以弹出菜单方式创建的规则添加到列表末尾。"
msgid "options_showResultProfileOnActionBadgeText"
msgstr "将最终使用的情景模式名称显示到徽标上。"
msgid "options_group_keyboardShortcut" msgid "options_group_keyboardShortcut"
msgstr "键盘快捷键" msgstr "键盘快捷键"

View File

@ -194,6 +194,8 @@ zeroBackground = (zeroStorage, opts) ->
shortTitle = 'Omega: ' + currentName # TODO: I18n. shortTitle = 'Omega: ' + currentName # TODO: I18n.
if profile.name != currentName if profile.name != currentName
shortTitle += ' => ' + profile.name # TODO: I18n. shortTitle += ' => ' + profile.name # TODO: I18n.
if options._options['-showResultProfileOnActionBadgeText']
badgeText = profile.name
return { return {
title: chrome.i18n.getMessage('browserAction_titleWithResult', [ title: chrome.i18n.getMessage('browserAction_titleWithResult', [
@ -202,6 +204,7 @@ zeroBackground = (zeroStorage, opts) ->
details details
]) ])
badgeText: badgeText
shortTitle: shortTitle shortTitle: shortTitle
icon: icon icon: icon
resultColor: resultColor resultColor: resultColor

View File

@ -53,9 +53,15 @@ class ChromeTabs
@actionForUrl(tab.url).then((action) => @actionForUrl(tab.url).then((action) =>
if not action if not action
@clearIcon tab.id @clearIcon tab.id
chrome.action.setBadgeText?(text: '', tabId: tab.id)
return return
@setIcon(action.icon, tab.id) @setIcon(action.icon, tab.id)
title = if @_canSetPopup() then action.title else action.shortTitle title = if @_canSetPopup() then action.title else action.shortTitle
if action.badgeText
chrome.action.setBadgeText?(
text: action.badgeText.substring(0,3),
tabId: tab.id
)
return chrome.action.setTitle({title: title, tabId: tab.id}) return chrome.action.setTitle({title: title, tabId: tab.id})
).catch((e) -> ).catch((e) ->
console.log('error:', e) console.log('error:', e)

View File

@ -8,6 +8,7 @@ module.exports = ->
"-confirmDeletion": true "-confirmDeletion": true
"-showInspectMenu": true "-showInspectMenu": true
"-addConditionsToBottom": false "-addConditionsToBottom": false
"-showResultProfileOnActionBadgeText": false
"-showExternalProfile": true "-showExternalProfile": true
"-downloadInterval": 1440 "-downloadInterval": 1440
"+proxy": "+proxy":

View File

@ -18,6 +18,10 @@ section.settings-group
label label
input(type='checkbox' ng-model='options["-addConditionsToBottom"]') input(type='checkbox' ng-model='options["-addConditionsToBottom"]')
span {{'options_addConditionsToBottom' | tr}} span {{'options_addConditionsToBottom' | tr}}
div.checkbox
label
input(type='checkbox' ng-model='options["-showResultProfileOnActionBadgeText"]')
span {{'options_showResultProfileOnActionBadgeText' | tr}}
section.settings-group section.settings-group
h3 {{'options_group_keyboardShortcut' | tr}} h3 {{'options_group_keyboardShortcut' | tr}}
p p