Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryohidaka/chrome-badge
Helper for displaying badges in chrome.action API.
https://github.com/ryohidaka/chrome-badge
badge chrome chrome-extension chrome-extensions ext
Last synced: 24 days ago
JSON representation
Helper for displaying badges in chrome.action API.
- Host: GitHub
- URL: https://github.com/ryohidaka/chrome-badge
- Owner: ryohidaka
- License: mit
- Created: 2024-01-29T09:18:05.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-10-01T23:28:15.000Z (about 2 months ago)
- Last Synced: 2024-10-04T21:12:41.542Z (about 1 month ago)
- Topics: badge, chrome, chrome-extension, chrome-extensions, ext
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/chrome-badge
- Size: 1.44 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# chrome-badge
[![npm version](https://badge.fury.io/js/chrome-badge.svg)](https://badge.fury.io/js/chrome-badge)
![build](https://github.com/ryohidaka/chrome-badge/workflows/Build/badge.svg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B6TVH92)
## Overview
Helper for displaying badges in `chrome.action` API.
## Installation
You can install this library using npm:
```shell
npm install chrome-badge
```## Methods
### `set`
Sets the text color and background color for badge of the action. The badge is displayed on top of the icon.
```typescript
import { Badge } from "chrome-badge";const text = "999";
const backgroundColor = "red";
const textColor = "white";Badge.set({ text, textColor, backgroundColor });
```### `get`
Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned.
```typescript
import { Alarm } from "chrome-alarms";const badge = await Badge.get();
console.log(badge);// Output:
// Object{
// backgroundColor: Array(4) [255, 0, 0, 255],
// text: "999",
// textColor: Array(4) [255, 255, 255, 255]
// }
```## Link
- [chrome.action](https://developer.chrome.com/docs/extensions/reference/api/action)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.