案例
// 注意仅支持在后台运行
chrome.browsingData.remove({since: Date.now() - 1000 * 60 * 60 * 24 * 7, // 整个浏览最近7天的origins: ["http://www.xxx.com"], // 如果设置了origins则仅对这里的地址,否则则所有站点
}, {"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
}, () => {console.log('清除完成')
})
参考资料
- chrome扩展api>chrome.browsingData