browsingData.removePasswords()
清除已保存的密码。
你可以使用 removalOptions
参数(一个 browsingData.RemovalOptions
对象),用于:
- 仅清除在特定时间之后保存的密码
- 控制是仅清除在普通网页上保存的密码,还是同时清除在托管应用程序和扩展程序上保存的密码。
这是一个返回 Promise
的异步函数。
语法
js
let removing = browser.browsingData.removePasswords(
removalOptions // RemovalOptions 对象
)
参数
removalOptions
-
object
。一个browsingData.RemovalOptions
对象,可用于仅清除在特定时间之后保存的密码,以及是仅清除在普通网页上保存的密码,还是同时清除在托管应用程序和扩展程序上保存的密码。
返回值
一个 Promise
,在移除完成时其会兑现且不带任何参数。如果发生任何错误,Promise
将被拒绝,并附带一个错误消息。
示例
清除上周保存的密码:
js
function onRemoved() {
console.log("已删除");
}
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);
清除所有已保存的密码:
js
function onRemoved() {
console.log("已删除");
}
function onError(error) {
console.error(error);
}
browser.browsingData.removePasswords({}).then(onRemoved, onError);
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
removePasswords |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
备注:
此 API 基于 Chromium 的 chrome.browsingData
API。