JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q88545F
  • License MIT

One-file interface to detect whether your content script have loaded.

Package Exports

  • webext-content-script-ping

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webext-content-script-ping) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

webext-content-script-ping

One-file interface to detect whether your content script have loaded.

Travis build status npm version

Install

npm install --save webext-content-script-ping
import {pingContentScript} from 'webext-content-script-ping';

Usage

From background.js, ping a tab id:

/* globals pingContentScript */
pingContentScript(tabId).then(() => {
    // the content script was loaded!
}, () => {
    // the content script was NOT loaded!
});

Plain files

  1. Include the file webext-content-script-ping.js in your manifest.json, both as a background script and content_script.
  2. In your background script only, run pingContentScript(tabId)

With a bundler

// background.js
import pingContentScript from 'webext-content-script-ping';
pingContentScript(tabId);
// content.js
import 'webext-content-script-ping'; // this only responds to the ping

API

pingContentScript(tabId)

Returns a Promise that succeeds if the content was loaded, fails if it wasn't.

It has an internal timeout of 300ms.

tabId

Type: number

The Tab's id as defined here: https://developer.chrome.com/extensions/tabs#type-Tab

License

MIT © Federico Brigante — Twitter