1.2.0 • Published 1 year ago

chrome-alarms v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

chrome-alarms

npm version build License

ko-fi

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

KeyTypeOptionalDescription
namestringName of this alarm.
periodInMinutesnumberIf 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.

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.1.0

1 year ago