recursal/MDN huggingface dataset:
scripting
=========

Inserts JavaScript and CSS into websites. This API offers two approaches to inserting content:

* `scripting.executeScript()`, `scripting.insertCSS()`, and `scripting.removeCSS()` that provide for one-off injections.
* `scripting.registerContentScripts()` that registers content scripts dynamically, which can then be retrieved with `scripting.getRegisteredContentScripts()` and unregistered with `scripting.unregisterContentScripts()`).

**Note:** Chrome restricts this API to Manifest V3. Firefox and Safari support this API in Manifest V2 and V3.

This API requires the `"scripting"` permission and host permission for the target in the tab into which JavaScript or CSS is injected.

Alternatively, you can get permission temporarily in the active tab and only in response to an explicit user action, by asking for the `"activeTab"` permission. However, the `"scripting"` permission is still required.

Types
-----

`scripting.ContentScriptFilter`

Specifies the IDs of scripts to retrieve with `scripting.getRegisteredContentScripts()` or to unregister with `scripting.unregisterContentScripts()`.

`scripting.ExecutionWorld`

Specifies the execution environment of a script injected with `scripting.executeScript()` or registered with `scripting.registerContentScripts()`.

`scripting.InjectionTarget`

Details of an injection target.

`scripting.RegisteredContentScript`

Details of a content script to be registered or that is registered.

Functions
---------

`scripting.executeScript()`

Injects JavaScript code into a page.

`scripting.getRegisteredContentScripts()`

Gets a list of registered content scripts.

`scripting.insertCSS()`

Injects CSS into a page.

`scripting.registerContentScripts()`

Registers a content script for future page loads.

`scripting.removeCSS()`

Removes CSS which was previously injected into a page by a `scripting.insertCSS()` call.

`scripting.updateContentScripts()`

Updates one or more content scripts already registered.

`scripting.unregisterContentScripts()`

Unregisters one or more content scripts.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.scripting` API.
extensionTypes
==============

Some common types used in other WebExtension APIs.

Types
-----

`extensionTypes.ImageDetails`

Details about the format and quality of an image.

`extensionTypes.ImageFormat`

The format of an image.

`extensionTypes.InjectDetails`

Injects details into a page.

`extensionTypes.RunAt`

The soonest that the JavaScript or CSS will be injected into the tab.

`extensionTypes.CSSOrigin`

Indicates whether a CSS stylesheet injected by `tabs.insertCSS` should be treated as an "author" or "user" stylesheet.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.extensionTypes` API. This documentation is derived from `extension_types.json` in the Chromium code.
management
==========

Get information about installed add-ons.

With the `management` API you can:

* get information about installed add-ons
* enable/disable add-ons
* uninstall add-ons
* find out which permission warnings are given for particular add-ons or manifests
* get notifications of add-ons being installed, uninstalled, enabled, or disabled.

Most of these operations require the "management" API permission. Operations that don't provide access to other add-ons don't require this permission.

Types
-----

`management.ExtensionInfo`

An object that contains information about an installed add-on.

Functions
---------

`management.getAll()`

Returns information about all installed add-ons.

`management.get()`

Returns information about a particular add-on, given its ID.

`management.getSelf()`

Returns information about the calling add-on.

`management.install()`

Installs a particular theme, given its URL at addons.mozilla.org.

`management.uninstall()`

Uninstalls a particular add-on, given its ID.

`management.uninstallSelf()`

Uninstalls the calling add-on.

`management.getPermissionWarningsById()`

Get the set of permission warnings for a particular add-on, given its ID.

`management.getPermissionWarningsByManifest()`

Get the set of permission warnings that would be displayed for the given manifest string.

`management.setEnabled()`

Enable/disable a particular add-on, given its ID.

Events
------

`management.onInstalled`

Fired when an add-on is installed.

`management.onUninstalled`

Fired when an add-on is uninstalled.

`management.onEnabled`

Fired when an add-on is enabled.

`management.onDisabled`

Fired when an add-on is disabled.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

Example extensions
------------------

* theme-switcher

**Note:** This API is based on Chromium's `chrome.management` API. This documentation is derived from `management.json` in the Chromium code.
clipboard
=========

The WebExtension `clipboard` API (which is different from the standard Clipboard API) enables an extension to copy items to the system clipboard. Currently the WebExtension `clipboard` API only supports copying images, but it's intended to support copying text and HTML in the future.

The WebExtension `clipboard` API exists primarily because the standard Clipboard API doesn't support writing images to the clipboard. The WebExtension `clipboard` API may be deprecated once the standard Clipboard API's support for non-text clipboard contents has entered general use.

Reading from the clipboard is not supported by this API, because the clipboard can already be read using the standard web platform APIs. See Interacting with the clipboard.

This API is based on Chrome's `clipboard` API, but that API is only available for Chrome apps, not extensions.

To use this API you need the `"clipboardWrite"` extension permission.

Functions
---------

`clipboard.setImageData()`

Copy an image to the clipboard.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:**

This API is based on Chromium's `chrome.clipboard` API.
devtools
========

Enables extensions to interact with the browser's Developer Tools. You use this API to create Developer Tools pages, interact with the window that is being inspected, inspect the page network usage.

To use this API, you must specify the `devtools_page` manifest key. The use of this manifest key triggers an install-time permission warning about devtools. To avoid an install-time permission warning, mark the feature as optional by listing the `"devtools"` permission in the `optional_permissions` manifest key.

> 
> NOTE: The "devtools" optional permission is only supported by Firefox and not Chrome (Chromium issue 1143015).
> 
> 
> 

Properties
----------

`devtools.inspectedWindow`

Interact with the window that Developer tools are attached to (inspected window). This includes obtaining the tab ID for the inspected page, evaluate the code in the context of the inspected window, reload the page, or obtain the list of resources within the page.

`devtools.network`

Obtain information about network requests associated with the window that the Developer Tools are attached to (the inspected window).

`devtools.panels`

Create User Interface panels that will be displayed inside User Agent Developer Tools.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.devtools` API.
dns
===

Enables an extension to resolve domain names.

To use this API, an extension must request the "dns" permission in its `manifest.json` file.

**Note:** DNS will fail with NS\_ERROR\_UNKNOWN\_PROXY\_HOST if proxying DNS over socks is enabled.

Functions
---------

`dns.resolve()`

Resolves the given hostname to a DNS record.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
extension
=========

Utilities related to your extension. Get URLs to resources packages with your extension. Get the `Window` object for your extension's pages. Get the values for various settings.

**Note:** **The messaging APIs in this module are deprecated** in favor of the equivalent APIs in the `runtime` module.

Types
-----

`extension.ViewType`

The type of extension view.

Properties
----------

`extension.lastError` 
Deprecated

Set for the lifetime of a callback if an asynchronous extension API has resulted in an error. If no error has occurred, `lastError` will be `undefined`.

`extension.inIncognitoContext`

`True` for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. (The latter only applies to extensions with '`split`' `incognito_behavior`.)

Functions
---------

`extension.getBackgroundPage()`

Returns the `Window` object for the background page running inside the current extension. Returns `null` if the extension has no background page.

`extension.getExtensionTabs()` 
Deprecated

Returns an array of the JavaScript Window objects for each of the tabs running inside the current extension.

`extension.getURL()` 
Deprecated

Converts a relative path within an extension install directory to a fully-qualified URL.

`extension.getViews()`

Returns an array of the `Window` objects for each of the pages running inside the current extension.

`extension.isAllowedIncognitoAccess()`

Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled '*Allowed in Incognito*' checkbox).

`extension.isAllowedFileSchemeAccess()`

Retrieves the state of the extension's access to the `file://` scheme (as determined by the user-controlled '*Allow access to File URLs*' checkbox).

`extension.sendRequest()` 
Deprecated

Sends a single request to other listeners within the extension.

`extension.setUpdateUrlData()`

Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the browser vendor's store.

Events
------

`extension.onRequest` 
Deprecated

Fired when a request is sent from either an extension process or a content script.

`extension.onRequestExternal` 
Deprecated

Fired when a request is sent from another extension.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

Example extensions
------------------

* beastify
* cookie-bg-picker
* find-across-tabs
* imagify
* notify-link-clicks-i18n
* proxy-blocker
* user-agent-rewriter

**Note:** This API is based on Chromium's `chrome.extension` API. This documentation is derived from `extension.json` in the Chromium code.
find
====

Finds text in a web page, and highlights matches.

To use this API you need to have the "find" permission.

Functions
---------

`find.find()`

Find text in a web page.

`find.highlightResults()`

Highlight the last set of matches found.

`find.removeHighlighting()`

Remove any highlighting.

Browser compatibility
---------------------

Example extensions
------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

* find-across-tabs
events
======

Common types used by APIs that dispatch events.

Types
-----

`events.Rule`

Description of a declarative rule for handling events.

`events.Event`

An object which allows the addition and removal of listeners for a browser event.

`events.UrlFilter`

Filters URLs for various criteria. If any of the given criteria match, then the whole filter matches.

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.events` API. This documentation is derived from `events.json` in the Chromium code.
browsingData.removeLocalStorage()
=================================

Clears any local storage created by websites.

You can use the `removalOptions` parameter, which is a `browsingData.RemovalOptions` object, to:

* clear only local storage objects created after a given time
* control whether to clear only local storage objects created by normal web pages or to clear objects created by hosted apps and extensions as well.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removeLocalStorage(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only local storage objects created by normal web pages or to clear objects created by hosted apps and extensions as well.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Remove all local storage:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeLocalStorage({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.
browsingData.removePasswords()
==============================

Clears saved passwords.

You can use the `removalOptions` parameter, which is a `browsingData.RemovalOptions` object, to:

* clear only passwords that were saved after a given time
* control whether to clear passwords that were saved on normal web pages or to clear passwords that were saved on hosted apps and extensions as well.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removePasswords(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only passwords that were saved after a given time, and whether to clear passwords that were saved on normal web pages or to clear passwords that were saved on hosted apps and extensions as well.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Remove passwords saved in the last week:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

function weekInMilliseconds() {
  return 1000 \* 60 \* 60 \* 24 \* 7;
}

let oneWeekAgo = new Date().getTime() - weekInMilliseconds();

browser.browsingData
  .removePasswords({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all saved passwords:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removePasswords({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.
browsingData.removeFormData()
=============================

Clears data that the browser has saved for autofilling forms.

You can use the `removalOptions` parameter, which is a `browsingData.RemovalOptions` object, to:

* clear only form data entered after a given time
* control whether to clear only form data entered in normal web pages or to clear data entered in hosted apps and extensions as well.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removeFormData(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only form data entered after a given time, and whether to clear only form data entered in normal web pages or to clear data entered in hosted apps and extensions as well.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Remove form data saved in the last week:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

function weekInMilliseconds() {
  return 1000 \* 60 \* 60 \* 24 \* 7;
}

let oneWeekAgo = new Date().getTime() - weekInMilliseconds();

browser.browsingData
  .removeFormData({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all saved form data:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeFormData({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.
browsingData.removeCache()
==========================

Clears the browser's cache.

Note that although this function can take a `browsingData.RemovalOptions` object, it will be ignored. The entire cache is always cleared when using this function.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removeCache(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions` Optional

`object`. A `browsingData.RemovalOptions` object. This parameter has no effect.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Clear the browser cache:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeCache({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.
browsingData.removeHistory()
============================

Clears the record of web pages that the user has visited (browsing history).

You can use the `removalOptions` parameter, which is a `browsingData.RemovalOptions` object, to:

* clear only records of web pages visited after a given time
* control whether to clear only records of normal web pages or to clear records of hosted apps and extensions as well.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removeHistory(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only records of web pages visited after a given time, and whether to clear only records of normal web pages or to clear records of hosted apps and extensions as well.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Remove records of pages visited in the last week:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

function weekInMilliseconds() {
  return 1000 \* 60 \* 60 \* 24 \* 7;
}

let oneWeekAgo = new Date().getTime() - weekInMilliseconds();

browser.browsingData
  .removeHistory({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all records of visited pages:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeHistory({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.
browsingData.removeDownloads()
==============================

Clears the browser's download history. Note that this does not delete the downloaded objects themselves, only records of downloads in the browser's history.

You can use the `removalOptions` parameter, which is a `browsingData.RemovalOptions` object, to:

* clear records of items downloaded after a given time
* control whether to clear only records of items downloaded from normal web pages or to clear records from hosted apps and extensions as well.

This is an asynchronous function that returns a `Promise`.

Syntax
------


```js
let removing = browser.browsingData.removeDownloads(
  removalOptions            // RemovalOptions object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only records created after a given time, and whether to clear only records of items downloaded from normal web pages or to clear records from hosted apps and extensions as well.

### Return value

A `Promise` that will be fulfilled with no arguments when the removal has finished. If any error occurs, the promise will be rejected with an error message.

Examples
--------

Remove records of objects downloaded in the last week:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

function weekInMilliseconds() {
  return 1000 \* 60 \* 60 \* 24 \* 7;
}

let oneWeekAgo = new Date().getTime() - weekInMilliseconds();

browser.browsingData
  .removeDownloads({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all records of downloaded objects:


```js
function onRemoved() {
  console.log("removed");
}

function onError(error) {
  console.error(error);
}

browser.browsingData.removeDownloads({}).then(onRemoved, onError);
```

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

**Note:** This API is based on Chromium's `chrome.browsingData` API.