webext-alert
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

webext-alert npm version

WebExtension module: alert() for background pages/workers in Web Extensions

  • Browsers: Chrome, Firefox, Safari
  • Manifest: v2 and v3
  • Contexts: All contexts

Install

You can download the standalone bundle and include it in your manifest.json.

Or use npm:

npm install webext-alert
import alert from 'webext-alert';

Usage

alert('Hello from background script!');

alert from service worker in MV3

API

alert(message)

Uses alert() wherever possible, but falls back to a custom window with the same content.

If the native alert is used, this will block the execution of the background script until the user closes the alert.

If the custom window is used, webextAlert will return a promise that resolves when the user closes the window.

Known issues

  • If the user is using a full screen window on macOS or they're on mobile, a whole new window will be opened instead of a popup. This is a limitation of the WebExtensions API.

Related

License

MIT © Federico Brigante

Package Sidebar

Install

npm i webext-alert

Weekly Downloads

258

Version

1.0.2

License

MIT

Unpacked Size

9.46 kB

Total Files

5

Last publish

Collaborators

  • fregante