Skip to content

Commit

Permalink
Rename to webext-detect
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jun 28, 2024
1 parent c25a910 commit 1ff33b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "webext-detect-page",
"name": "webext-detect",
"version": "5.0.1",
"description": "Detects where the current browser extension code is being run. Compatible with Firefox, Chrome and derivates.",
"keywords": [
Expand All @@ -17,7 +17,7 @@
"webext",
"where"
],
"repository": "fregante/webext-detect-page",
"repository": "fregante/webext-detect",
"funding": "https://github.com/sponsors/fregante",
"license": "MIT",
"author": "Federico Brigante <me@fregante.com> (https://fregante.com)",
Expand Down
16 changes: 9 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# webext-detect-page [![](https://img.shields.io/npm/v/webext-detect-page.svg)](https://www.npmjs.com/package/webext-detect-page)
# webext-detect [![](https://img.shields.io/npm/v/webext-detect.svg)](https://www.npmjs.com/package/webext-detect)

> Detects where the current browser extension code is being run. Chrome and Firefox.
> Detects where the current browser extension code is being run.
> This package was recently renamed from `webext-detect-page` to `webext-detect`
## Install

You can download the [standalone bundle](https://bundle.fregante.com/?pkg=webext-detect-page&global=window) and include it in your `manifest.json`.
You can download the [standalone bundle](https://bundle.fregante.com/?pkg=webext-detect&global=window) and include it in your `manifest.json`.

Or use `npm`:

```sh
npm install webext-detect-page
npm install webext-detect
```

```js
Expand All @@ -18,13 +20,13 @@ import {
isBackgroundPage,
isContentScript,
isOptionsPage,
} from 'webext-detect-page';
} from 'webext-detect';
```

## Usage

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

if (isBackgroundPage()) {
// Run background code, e.g.
Expand Down Expand Up @@ -95,7 +97,7 @@ Returns the first matching context among those defined in `index.ts`, depending
The calls are automatically cached so, if you're using this in a test environment, import and call this function first to ensure that the environment is "detected" every time:

```js
import {disableWebextDetectPageCache} from 'webext-detect-page';
import {disableWebextDetectPageCache} from 'webext-detect';
disableWebextDetectPageCache();
```

Expand Down

0 comments on commit 1ff33b7

Please sign in to comment.