From 0e858401dccc94ee44a99452eafbb5e28b5bb338 Mon Sep 17 00:00:00 2001 From: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:38:23 +0530 Subject: [PATCH] feat: add monetization state to browser action's tooltip text (#357) --- src/_locales/en/messages.json | 6 ++++++ src/background/services/tabEvents.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 80d38f97..b2dfb478 100755 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -15,6 +15,12 @@ "message": "Permission to access your data for all websites is required to use Web Monetization.", "description": "..." }, + "monetizationActiveShort": { + "message": "Active" + }, + "monetizationInactiveShort": { + "message": "Inactive" + }, "siteNotMonetized": { "message": "This website is not monetized." } diff --git a/src/background/services/tabEvents.ts b/src/background/services/tabEvents.ts index 8d083b47..ddd4bb24 100644 --- a/src/background/services/tabEvents.ts +++ b/src/background/services/tabEvents.ts @@ -63,13 +63,19 @@ export class TabEvents { ) => { const { enabled } = await this.storage.get(['enabled']) + let title = this.browser.i18n.getMessage('appName') let iconData = enabled ? ICONS.default : ICONS.warning if (enabled && payload) { const { value: isTabMonetized } = payload iconData = isTabMonetized ? ICONS.active : ICONS.inactive + const tabStateText = isTabMonetized + ? this.browser.i18n.getMessage('monetizationActiveShort') + : this.browser.i18n.getMessage('monetizationInactiveShort') + title = `${title} - ${tabStateText}` } const tabId = sender && getTabId(sender) await this.browser.action.setIcon({ path: iconData, tabId }) + await this.browser.action.setTitle({ title, tabId }) } }