chrome-alarms
v1.2.0
Published
Helper for chrome.alarms API.
Downloads
11
Maintainers
Readme
chrome-alarms
Overview
Helper for chrome.alarms
API.
Notes
To use the chrome.alarms
API, declare the "alarms"
permission in the manifest:
{
"name": "My extension",
"permissions": ["alarms"]
}
Installation
You can install this library using npm:
npm install chrome-alarms
Properties
| Key | Type | Optional | Description |
| ----------------- | ------ | -------- | --------------------------------------------------------------------------------------------- |
| name
| string | | Name of this alarm. |
| periodInMinutes
| number | ◯ | If not null, the alarm is a repeating alarm and will fire again in periodInMinutes
minutes. |
Methods
create
Creates an alarm. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
import { Alarm } from "chrome-alarms";
const name = "test";
const periodInMinutes = 1;
await Alarm.create(name, periodInMinutes);
clear
Clears the alarm with the given name.
import { Alarm } from "chrome-alarms";
const name = "test";
await Alarm.clear(name);
clearAll
Clears all alarms.
import { Alarm } from "chrome-alarms";
await Alarm.clearAll();
get
Retrieves details about the specified alarm.
import { Alarm } from "chrome-alarms";
const name = "test";
const alarm = await Alarm.get(name);
console.log(alarm);
// Output: Object{ name: "test", periodInMinutes: 1, scheduledTime: 1706435598914.826 }
getAll
Gets an array of all the alarms.
import { Alarm } from "chrome-alarms";
const alarms = await Alarm.getAll();
console.log(alarms);
// Output: Array[{ name: "test", periodInMinutes: 1, scheduledTime: 1706435598914.826 }]
Link
License
This project is licensed under the MIT License - see the LICENSE file for details.