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 - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

19

index.js

@@ -15,13 +15,10 @@ let cache = true;

/** Indicates whether the code is being run on http(s):// pages (it could be in a content script or regular web context) */
export const isWebPage = once(() => { var _a; return (_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.protocol.startsWith('http'); });
export const isWebPage = once(() => globalThis.location?.protocol.startsWith('http'));
/** Indicates whether the code is being run in extension contexts that have access to the chrome API */
export const isExtensionContext = once(() => { var _a; return typeof ((_a = globalThis.chrome) === null || _a === void 0 ? void 0 : _a.extension) === 'object'; });
export const isExtensionContext = once(() => typeof globalThis.chrome?.extension === 'object');
/** Indicates whether the code is being run in a content script */
export const isContentScript = once(() => isExtensionContext() && isWebPage());
/** Indicates whether the code is being run in a background page */
export const isBackgroundPage = once(() => {
var _a, _b;
return isExtensionContext() && (location.pathname === '/_generated_background_page.html' ||
((_b = (_a = chrome.extension) === null || _a === void 0 ? void 0 : _a.getBackgroundPage) === null || _b === void 0 ? void 0 : _b.call(_a)) === globalThis.window);
});
export const isBackgroundPage = once(() => isExtensionContext() && (location.pathname === '/_generated_background_page.html'
|| chrome.extension?.getBackgroundPage?.() === globalThis.window));
/** Indicates whether the code is being run in an options page. This only works if the current page’s URL matches the one specified in the extension's `manifest.json` */

@@ -33,3 +30,3 @@ export const isOptionsPage = once(() => {

const { options_ui } = chrome.runtime.getManifest();
if ((options_ui === null || options_ui === void 0 ? void 0 : options_ui.page) !== 'string') {
if (options_ui?.page !== 'string') {
return false;

@@ -53,6 +50,6 @@ }

/** Loosely detect Firefox via user agent */
export const isFirefox = () => { var _a; return (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent.includes('Firefox'); };
export const isFirefox = () => globalThis.navigator?.userAgent.includes('Firefox');
/** Loosely detect Chrome via user agent (might also include Chromium and forks like Opera) */
export const isChrome = () => { var _a; return (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent.includes('Chrome'); };
export const isChrome = () => globalThis.navigator?.userAgent.includes('Chrome');
/** Loosely detect Safari via user agent */
export const isSafari = () => { var _a; return !isChrome() && ((_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent.includes('Safari')); };
export const isSafari = () => !isChrome() && globalThis.navigator?.userAgent.includes('Safari');
{
"name": "webext-detect-page",
"version": "3.0.0",
"version": "3.0.1",
"description": "Detects where the current browser extension code is being run. Compatible with Firefox, Chrome and derivates.",

@@ -32,3 +32,3 @@ "keywords": [

"build": "tsc",
"prepack": "tsc --sourceMap false",
"prepare": "tsc --sourceMap false",
"test": "xo && tsc && node index.js",

@@ -48,6 +48,6 @@ "watch": "tsc --watch"

"@sindresorhus/tsconfig": "^1.0.2",
"@types/chrome": "0.0.145",
"typescript": "^4.3.4",
"xo": "^0.40.3"
"@types/chrome": "0.0.148",
"typescript": "^4.3.5",
"xo": "^0.42.0"
}
}
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