A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.chrome.com/docs/extensions/reference/api/browsingData below:

chrome.browsingData | API | Chrome for Developers

Skip to main content chrome.browsingData

Stay organized with collections Save and categorize content based on your preferences.

Description

Use the chrome.browsingData API to remove browsing data from a user's local profile.

Permissions

browsingData

You must declare the "browsingData" permission in the extension manifest to use this API.

{
  "name": "My extension",
  ...
  "permissions": [
    "browsingData",
  ],
  ...
}
Concepts and usage

The simplest use-case for this API is a a time-based mechanism for clearing a user's browsing data. Your code should provide a timestamp which indicates the historical date after which the user's browsing data should be removed. This timestamp is formatted as the number of milliseconds since the Unix epoch (which can be retrieved from a JavaScript Date object using the getTime() method).

For example, to clear all of a user's browsing data from the last week, you might write code as follows:

var callback = function () {
  // Do something clever here once data has been removed.
};

var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.remove({
  "since": oneWeekAgo
}, {
  "appcache": true,
  "cache": true,
  "cacheStorage": true,
  "cookies": true,
  "downloads": true,
  "fileSystems": true,
  "formData": true,
  "history": true,
  "indexedDB": true,
  "localStorage": true,
  "passwords": true,
  "serviceWorkers": true,
  "webSQL": true
}, callback);

The chrome.browsingData.remove() method lets you remove various types of browsing data with a single call, and will be much faster than calling multiple more specific methods. If, however, you only want to clear one specific type of browsing data (cookies, for example), the more granular methods offer a readable alternative to a call filled with JSON.

var callback = function () {
  // Do something clever here once data has been removed.
};

var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.removeCookies({
  "since": oneWeekAgo
}, callback);

If the user is syncing their data, chrome.browsingData.remove() may automatically rebuild the cookie for the Sync account after clearing it. This is to ensure that Sync can continue working, so that the data can be eventually deleted on the server. However the more specific chrome.browsingData.removeCookies() can be used to clear the cookie for the Sync account, and Sync will be paused in this case.

Important: Removing browsing data involves a good deal of heavy lifting in the background, and can take tens of seconds to complete, depending on a user's profile. You should use either the returned promise or the callback to keep your users up to date on the removal's status. Specific origins

To remove data for a specific origin or to exclude a set of origins from deletion, you can use the RemovalOptions.origins and RemovalOptions.excludeOrigins parameters. They can only be applied to cookies, cache, and storage (CacheStorage, FileSystems, IndexedDB, LocalStorage, ServiceWorkers, and WebSQL).

chrome.browsingData.remove({
  "origins": ["https://www.example.com"]
}, {
  "cacheStorage": true,
  "cookies": true,
  "fileSystems": true,
  "indexedDB": true,
  "localStorage": true,
  "serviceWorkers": true,
  "webSQL": true
}, callback);
Important: As cookies are scoped more broadly than other types of storage, deleting cookies for an origin will delete all cookies of the registrable domain. For example, deleting data for https://www.example.com will delete cookies with a domain of .example.com as well. Origin types

Adding an originTypes property to the APIs options object lets you specify which types of origins ought to be effected. Origins are divided into three categories:

We could adjust the previous example to remove only data from protected websites as follows:

var callback = function () {
  // Do something clever here once data has been removed.
};

var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.remove({
  "since": oneWeekAgo,
  "originTypes": {
    "protectedWeb": true
  }
}, {
  "appcache": true,
  "cache": true,
  "cacheStorage": true,
  "cookies": true,
  "downloads": true,
  "fileSystems": true,
  "formData": true,
  "history": true,
  "indexedDB": true,
  "localStorage": true,
  "passwords": true,
  "serviceWorkers": true,
  "webSQL": true
}, callback);
Warning: Be careful with the protectedWeb and extension origin types. These are destructive operations that may surprise your users if they're not well-informed about what to expect when your extension removes data on their behalf. Examples

To try this API, install the browsingData API example from the chrome-extension-samples repository.

Types

DataTypeSet

A set of data types. Missing data types are interpreted as false.

Properties

RemovalOptions

Options that determine exactly what data will be removed.

Properties Methods

remove()

chrome.browsingData.remove(
  options: RemovalOptions,
  dataToRemove: DataTypeSet,
)
: Promise<void>

Clears various types of browsing data stored in a user's profile.

Parameters

removeAppcache()

chrome.browsingData.removeAppcache(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' appcache data.

removeCache()

chrome.browsingData.removeCache(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's cache.

removeCacheStorage()

chrome.browsingData.removeCacheStorage(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' cache storage data.

removeCookies()

chrome.browsingData.removeCookies(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's cookies and server-bound certificates modified within a particular timeframe.

removeDownloads()

chrome.browsingData.removeDownloads(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's list of downloaded files (not the downloaded files themselves).

removeFileSystems()

chrome.browsingData.removeFileSystems(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' file system data.

removeFormData()

chrome.browsingData.removeFormData(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's stored form data (autofill).

removeHistory()

chrome.browsingData.removeHistory(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's history.

removeIndexedDB()

chrome.browsingData.removeIndexedDB(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' IndexedDB data.

removeLocalStorage()

chrome.browsingData.removeLocalStorage(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' local storage data.

removePasswords()

chrome.browsingData.removePasswords(
  options: RemovalOptions,
)
: Promise<void>

Clears the browser's stored passwords.

removePluginData()

Deprecated since Chrome 88

chrome.browsingData.removePluginData(
  options: RemovalOptions,
)
: Promise<void>

Support for Flash has been removed. This function has no effect.

Clears plugins' data.

removeServiceWorkers()

chrome.browsingData.removeServiceWorkers(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' service workers.

removeWebSQL()

chrome.browsingData.removeWebSQL(
  options: RemovalOptions,
)
: Promise<void>

Clears websites' WebSQL data.

settings()

chrome.browsingData.settings(): Promise<object>

Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-11 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4