New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webext-detect-page

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webext-detect-page

Detects where the current browser extension code is being run. Compatible with Firefox, Chrome and derivates.

  • 2.0.4
  • npm
  • Socket score

Version published
Weekly downloads
612
decreased by-22.63%
Maintainers
1
Weekly downloads
 
Created
Source

webext-detect-page

Detects where the current browser extension code is being run. Chrome and Firefox.

Install

You can just download the standalone bundle (it might take a minute to download) and include the file in your manifest.json.

Or use npm:

npm install webext-detect-page
 // This module is only offered as a ES Module
import {
	isBackgroundPage,
	isContentScript,
	isOptionsPage
} from 'webext-detect-page';

Usage

import {isBackgroundPage} from 'webext-detect-page';

if (isBackgroundPage()) {
	// Run background code, e.g.
	browser.runtime.onMessage.addListener(console.log);
} else if (isContentScript) {
	// Run content script code, e.g.
	browser.runtime.sendMessage('wow!');
}

API

isBackgroundPage()

Returns a boolean that indicates whether the code is being run in a background page.

isContentScript()

Returns a boolean that indicates whether the code is being run in a content script.

isOptionsPage()

Returns a boolean that indicates whether the code is being run in an options page. This only works if the URL matches the one specified in the extension's manifest.json

License

MIT © Federico Brigante

Keywords

FAQs

Package last updated on 07 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc