Skip to content

ryohidaka/chrome-badge

Repository files navigation

chrome-badge

npm version build License

ko-fi

Overview

Helper for displaying badges in chrome.action API.

Installation

You can install this library using npm:

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.

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.

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

License

This project is licensed under the MIT License - see the LICENSE file for details.