Skip to content

Commit

Permalink
feat: add monetization state to browser action's tooltip text (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi committed Jun 21, 2024
1 parent e3f0fb7 commit 0e85840
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
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('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 })
}
}

0 comments on commit 0e85840

Please sign in to comment.