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
.
var getSettings = browser.browsingData.settings()
None.
A
Promise
that will be fulfilled with an object containing the settings information. This object has three properties:
选项
。
browsingData.RemovalOptions
RemovalOptions
object describing the removal options currently selected.
dataToRemove
. 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
browsingData.DataTypeSet
true
if that type is selected for removal and
false
否则。
dataRemovalPermitted
. This will contain a property for every data type that can be toggled in the browser's UI. Each will have a value of
browsingData.DataTypeSet
true
if the administrator of the device has allowed the user to remove that type, and
false
否则。
If any error occurs, the promise will be rejected with an error message.
BCD tables only load in the browser
Log current settings:
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);
注意:
This API is based on Chromium's
chrome.browsingData
API。
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.
最后修改: , 由 MDN 贡献者