Skip to content

Commit

Permalink
feat: add monetization state to browser action's tooltip text
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi committed Jun 21, 2024
1 parent e3f0fb7 commit fa1a8b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"message": "Permission to access your data for all websites is required to use Web Monetization.",
"description": "..."
},
"siteMonetized": {
"message": "Monetizing…"
},
"siteNotMonetized": {
"message": "This website is not monetized."
}
Expand Down
6 changes: 6 additions & 0 deletions src/background/services/tabEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('siteMonetized')
: this.browser.i18n.getMessage('siteNotMonetized')
title = `${title}\n${tabStateText}`
}
const tabId = sender && getTabId(sender)

await this.browser.action.setIcon({ path: iconData, tabId })
await this.browser.action.setTitle({ title, tabId })
}
}

0 comments on commit fa1a8b9

Please sign in to comment.