我正在尝试从Chrome扩展程序中删除用户浏览器中的所有cookie。
我的代码如下(我正在使用可选权限)
chrome.permissions.request({permissions: ["cookies"]}, granted=>{
if (!granted)
return console.log('!granted');
chrome.cookies.getAll({}, cookies=>{
_.forEach(cookies, cookie=>{
chrome.cookies.remove({name: cookie.name});
});
});
});
如果我在控制台上运行此代码,它可以工作,但是从扩展名中我可以得到:
Error in response to cookies.getAll: Error: Invalid value for argument 1. Property 'url': Property is required.
at chrome-extension://lbebeoldpnjnojibgdcjhnbkgjefhfdb/js/bext/lum/chrome/pub/ui.js:639:48
at Pn (chrome-extension://lbebeoldpnjnojibgdcjhnbkgjefhfdb/js/lodash.min.js:9:530)
at Function.<anonymous> (chrome-extension://lbebeoldpnjnojibgdcjhnbkgjefhfdb/js/lodash.min.js:30:66)
at Object.callback (chrome-extension://lbebeoldpnjnojibgdcjhnbkgjefhfdb/js/bext/lum/chrome/pub/ui.js:637:46)
at Object.callback (chrome-extension://lbebeoldpnjnojibgdcjhnbkgjefhfdb/js/bext/lum/chrome/pub/ui.js:636:40)
但是在Chrome开发者文档中,它没有提及任何有关必需参数的信息