recursal/MDN huggingface dataset:
browsingData.removeCookies()
============================

Clears the browser's cookies.

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

* clear only cookies created after a given time
* control whether to clear cookies only set from normal web pages or to clear cookies set from hosted apps and extensions as well.

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

Syntax
------


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

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only cookies created after a given time, and whether to clear cookies only set from normal web pages or to clear cookies set 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 cookies created 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
  .removeCookies({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all cookies:

**Warning:** Using the API to remove all cookies will, simultaneously, clear all local storage objects (including those of other extensions).

If you want to clear all cookies without disrupting local storage facilities, use browser.cookies to loop through and remove the contents of all cookie stores.


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

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

browser.browsingData.removeCookies({}).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.DataTypeSet
========================

The **`browsingData.DataTypeSet`** type describes a set of data types.

It contains a number of boolean properties. The name of each property is the name of a particular type of browsing data: "downloads", "history" and so on. All properties are optional.

This type is used:

* in `browsingData.remove()` to describe which data types to remove
* in `browsingData.settings()` to describe which data types are currently selected in the browser's "Clear History" feature.
Type
----

Values of this type are objects. They contain the following properties:

`cache` Optional

`boolean`. The browser's cache.

`cookies` Optional

`boolean`. Cookies acquired while browsing.

`downloads` Optional

`boolean`. The user's download history.

`fileSystems` Optional

`boolean`. Website's file systems.

`formData` Optional

`boolean`. Saved form data, for autocomplete.

`history` Optional

`boolean`. The user's browsing history.

`indexedDB` Optional

`boolean`. IndexedDB data.

`localStorage` Optional

`boolean`. Local storage data.

`passwords` Optional

`boolean`. Saved passwords, for autocomplete.

`pluginData` Optional

`boolean`. Stored data associated with plugins.

`serverBoundCertificates` Optional

`boolean`. Stored server-bound certificates.

`serviceWorkers` Optional

`boolean`. Data cached by service workers.

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.removePluginData()
===============================

Clears data stored by browser plugins.

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

* clear only plugin data stored after a given time
* control whether to clear only data stored by plugins running in normal web pages or to clear data stored by plugins running in hosted apps and extensions as well.

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

Syntax
------


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

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to clear only plugin data stored after a given time, and whether to clear only data stored by plugins running in normal web pages or to clear data stored by plugins running 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 data stored by plugins 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
  .removePluginData({ since: oneWeekAgo })
  .then(onRemoved, onError);
```


Remove all data stored by plugins:


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

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

browser.browsingData.removePluginData({}).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.settings()
=======================

Browsers have a built-in "Clear History" feature, which enables the user to clear various types of browsing data. This has a UI that enables the user to select what type of data to remove (e.g. history, downloads, …) and how far back in time to remove data.

This function returns the current value of these settings.

Note that not all data types will always be removable through the UI, and some UI options may map to more than one data type.

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

Syntax
------


```js
let getSettings = browser.browsingData.settings()
```

### Parameters

None.

### Return value

A `Promise` that will be fulfilled with an object containing the settings information. This object has three properties:

`options`

``browsingData.RemovalOptions``. A `RemovalOptions` object describing the removal options currently selected.

`dataToRemove`

``browsingData.DataTypeSet``. This will contain a property for every data type that can be toggled in the browser's UI. Each property will have a value of `true` if that type is selected for removal and `false` otherwise.

`dataRemovalPermitted`

``browsingData.DataTypeSet``. This will contain a property for every data type that can be toggled in the browser's UI. Each will have a value of `true` if the administrator of the device has allowed the user to remove that type, and `false` otherwise.

If any error occurs, the promise will be rejected with an error message.

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

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

Examples
--------

Log current settings:


```js
function onGotSettings(settings) {
  console.log(settings.options);
  console.log(settings.dataToRemove);
  console.log(settings.dataRemovalPermitted);
}

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

browser.browsingData.settings().then(onGotSettings, onError);
```


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

The **`browsingData.RemovalOptions`** type contains options to control certain aspects of browsing data removal.

Type
----

Values of this type are objects. They contain the following properties:

`cookieStoreId` Optional

`string`. This property only applies to cookies and indexedDB items. The removal is limited to items belonging to a specific cookie store as specified by the ID. See Work with contextual identities for more information.

**Note:** On Firefox Nightly removal of localStorage items by `cookieStoreId` is also supported.

`hostnames` Optional

`Array` of `string`. This property applies to cookie, indexedDB, local storage, and service worker registration items. Remove only cookie, indexedDB, local storage, and service worker registration items associated with these hostnames.

You must pass in just a hostname here, without protocol (for example, "google.com" not "https://google.com"). You can use the `URL` interface to parse a raw URL and retrieve the hostname. Items associated with subdomains of a given hostname are *not* removed: you must explicitly list subdomains.

`originTypes` Optional

`object`. Used to control whether to remove data only from normal web pages, or also from hosted web apps and extensions. If this option is omitted, only data from normal web pages ("`unprotectedWeb`") is removed. Before removing data from web apps or extensions, be very careful to ensure that this is really what the user wants.

This object may contain any of the following properties:

`unprotectedWeb` Optional

`boolean`. If present and `true`, remove data from normal web pages.

`protectedWeb` Optional

`boolean`. If present and `true`, remove data from websites that have been installed as hosted apps.

`extension` Optional

`boolean`. If present and `true`, remove data from extensions.


`since` Optional

`number`. How far back in time to remove data, given in milliseconds since the UNIX epoch. Note that when removing the browser cache, the entire cache is always removed and this option is ignored. If the `since` property is omitted, it defaults to 0, which means "forever".

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.remove()
=====================

Removes the specified browsing data.

The browsing data to be removed is specified in the `dataTypes` option, which is a `browsingData.DataTypeSet` object.

You can use the `removalOptions` option, which is a `browsingData.RemovalOptions` object, to control how far back in time to remove data and whether to remove data only from normal web pages or to remove data from hosted apps and extensions as well.

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

Syntax
------


```js
let removing = browser.browsingData.remove(
  removalOptions,            // RemovalOptions object
  dataTypes                  // DataTypeSet object
)
```

### Parameters

`removalOptions`

`object`. A `browsingData.RemovalOptions` object, which may be used to control how far back in time to remove data, and whether to remove data from hosted web apps and extensions, or just normal web pages.

`dataTypes`

`object`. A `browsingData.DataTypeSet` object, describing the types of data to remove (e.g. history, downloads, …).

### 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 download history and browsing history for 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
  .remove({ since: oneWeekAgo }, { downloads: true, history: true })
  .then(onRemoved, onError);
```


Remove all download and browsing history:


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

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

browser.browsingData
  .remove({}, { downloads: true, history: true })
  .then(onRemoved, onError);
```

### Example extensions

* forget-it
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.
theme.update()
==============

Updates the browser theme according to the content of the `Theme` object.

To use this method, an extension must request the "theme" permission in its manifest.json file.

Syntax
------


```js
browser.theme.update(
  windowId,    // integer
  theme        // object
)
```

### Parameters

`windowId` Optional

`integer`. The ID of a window. If this is provided, the theme is applied only to that window. If it is omitted, the theme is applied to all windows.

`theme`

`object`. A `Theme` object specifying values for the UI elements you want to modify.

Examples
--------

Sets the browser theme to use a sun graphic with a complementary background color:


```js
const suntheme = {
  images: {
    theme\_frame: "sun.jpg",
  },
  colors: {
    frame: "#CF723F",
    tab\_background\_text: "#111",
  },
};

browser.theme.update(suntheme);
```


Set the theme for the focused window only:


```js
const day = {
  images: {
    theme\_frame: "sun.jpg",
  },
  colors: {
    frame: "#CF723F",
    tab\_background\_text: "#111",
  },
};

browser.menus.create({
  id: "set-theme",
  title: "set theme",
  contexts: ["all"],
});

async function updateThemeForCurrentWindow() {
  let currentWindow = await browser.windows.getLastFocused();
  browser.theme.update(currentWindow.id, day);
}

browser.menus.onClicked.addListener(updateThemeForCurrentWindow);
```

### Example extensions

* dynamic-theme
* private-browsing-theme
Browser compatibility
---------------------

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

Fires when a theme supplied as a browser extension is applied or removed. Specifically:

* when a static theme is installed
* when a dynamic theme calls `theme.update()` or `theme.reset()`
* when a theme gets uninstalled.

This event is not fired for changes to the built-in themes.

Syntax
------


```js
browser.theme.onUpdated.addListener(listener)
browser.theme.onUpdated.removeListener(listener)
browser.theme.onUpdated.hasListener(listener)
```


Events have three functions:

`addListener(listener)`

Adds a listener to this event.

`removeListener(listener)`

Stop listening to this event. The `listener` argument is the listener to remove.

`hasListener(listener)`

Check whether `listener` is registered for this event. Returns `true` if it is listening, `false` otherwise.

addListener syntax
------------------

### Parameters

`listener`

The function called when this event occurs. The function is passed these arguments:

`updateInfo`

`object`. An object containing two properties:

`theme`

`object`. If the event fired because an extension-supplied theme was removed, this is an empty object. If it fired because an extension-supplied theme was applied, then it is a `theme.Theme` object representing the theme that was applied.

`windowId` Optional

`integer`. The ID of the window in which the theme was updated. If this property is not present, the theme was updated in all windows.


Examples
--------


```js
function handleUpdated(updateInfo) {
  if (updateInfo.theme.colors) {
    console.log(`Theme was applied: ${updateInfo.theme}`);
  } else {
    console.log(`Theme was removed`);
  }
}

browser.theme.onUpdated.addListener(handleUpdated);
```

### Example extensions

* theme-integrated-sidebar
Browser compatibility
---------------------

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

A Theme object represents the specification of a theme.

Type
----

A JSON object that takes the same properties as the "theme" manifest key.

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
theme.reset()
=============

Resets any theme applied using the `theme.update()` method.

To use this method, an extension must request the "theme" permission in its manifest.json file.

Note that this always reset the theme back to the original default theme, even if the user selected a different theme before this extension's theme was applied (see bug 1415267).

Syntax
------


```js
browser.theme.reset(
  windowId     // integer
)
```

### Parameters

`windowId` Optional

`integer`. The ID of a window. If this is provided, the theme applied to that window is reset. If it is omitted, the theme is reset on all windows.

Examples
--------

This code applies a theme, then removes it when the user clicks a browser action:


```js
browser.theme.update(themes.night);

browser.browserAction.onClicked.addListener(() => {
  browser.theme.reset();
});
```

### Example extensions

* private-browsing-theme
Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
theme.getCurrent()
==================

Gets the current theme as a `Theme` object.

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

Syntax
------


```js
let getting = browser.theme.getCurrent(
  windowId    // integer
)
```

### Parameters

`windowId` Optional

`integer`. The ID of a window. If this is provided, the theme resolved is the one applied to that window. If it is omitted, the theme resolved is the one applied to the most recently focused window.

### Return value

A `Promise`. The promise is fulfilled with a `theme.Theme` object representing the theme applied to the given window. If no extension-supplied theme has been applied to the given window, it is fulfilled with an empty object.

Examples
--------

Gets the properties `frame` and `toolbar` colors of the current theme:


```js
function getStyle(themeInfo) {
  if (themeInfo.colors) {
    console.log(`accent color: ${themeInfo.colors.frame}`);
    console.log(`toolbar: ${themeInfo.colors.toolbar}`);
  }
}

async function getCurrentThemeInfo() {
  const themeInfo = await browser.theme.getCurrent();
  getStyle(themeInfo);
}

getCurrentThemeInfo();
```

### Example extensions

* theme-integrated-sidebar
Browser compatibility
---------------------

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

The `privacy.network` property contains privacy-related network settings. Each property is a `types.BrowserSetting` object.

Default values for these properties tend to vary across browsers.

Properties
----------

`networkPredictionEnabled`

A `types.BrowserSetting` object whose underlying value is a boolean. If `true`, the browser attempts to speed up web browsing by pre-resolving DNS entries, prerendering sites (using, for example, `<link rel='prefetch' …>`), and preemptively opening TCP and TLS connections to servers.

`peerConnectionEnabled`

A `types.BrowserSetting` object whose underlying value is a boolean. If `false`, the `RTCPeerConnection` interface is disabled. Note that `getUserMedia()` is *not* affected by this setting.

`webRTCIPHandlingPolicy`

A `types.BrowserSetting` object whose underlying value is a string. This setting allows users to specify the media performance/privacy tradeoffs which affect how WebRTC traffic will be routed and how much local address information is exposed. It may take any one of the following values, from least private to most private:

* `default`
* `default_public_and_private_interfaces`
* `default_public_interface_only`
* `disable_non_proxied_udp`
* `proxy_only` (only connections using TURN on a TCP connection through a proxy are allowed)

`httpsOnlyMode`

 This setting allows your extension to determine if a user has enabled
 HTTPS-Only mode. This property is read-only on all platforms. Its underlying value is a string that may take one of three values:


* `"always"`: HTTPS-Only mode is on.
* `"never"`: HTTPS-Only mode is off.
* `"private_browsing"`: HTTPS-Only mode is on in private browsing windows only.

`globalPrivacyControl`

 this setting allows your extension to determine if a user has enabled
 Global Privacy Control. This property is read-only on all platforms. Its underlying value is a boolean where `true` indicates that the browser sends Global Privacy Control signals and `false` indicates the browser does not send the signals.


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

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

Examples
--------

Set the `webRTCIPHandlingPolicy` property:


```js
function onSet(result) {
  if (result) {
    console.log("success");
  } else {
    console.log("failure");
  }
}

browser.browserAction.onClicked.addListener(() => {
  let getting = browser.privacy.network.webRTCIPHandlingPolicy.get({});
  getting.then((got) => {
    console.log(got.value);
    if (
      got.levelOfControl === "controlled\_by\_this\_extension" ||
      got.levelOfControl === "controllable\_by\_this\_extension"
    ) {
      let setting = browser.privacy.network.webRTCIPHandlingPolicy.set({
        value: "default\_public\_interface\_only",
      });
      setting.then(onSet);
    } else {
      console.log("Not able to set webRTCIPHandlingPolicy");
    }
  });
});
```


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

The `privacy.services` property contains privacy-related settings controlling services offered by the browser or by third parties. Each property is a `types.BrowserSetting` object.

Properties
----------

`passwordSavingEnabled`

A `types.BrowserSetting` object whose underlying value is a boolean. If `true`, the browser's password manager will offer to store passwords when the user enters them. Defaults to `true`.

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

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

Examples
--------

Disable the password manager if possible.


```js
function onSet(result) {
  if (result) {
    console.log("success");
  } else {
    console.log("failure");
  }
}

let getting = browser.privacy.services.passwordSavingEnabled.get({});
getting.then((got) => {
  console.log(got.value);
  if (
    got.levelOfControl === "controlled\_by\_this\_extension" ||
    got.levelOfControl === "controllable\_by\_this\_extension"
  ) {
    let setting = browser.privacy.services.passwordSavingEnabled.set({
      value: false,
    });
    setting.then(onSet);
  } else {
    console.log("Not able to set passwordSavingEnabled");
  }
});
```


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