I have tried modifying my code so it looks similar to this answer.
Hello, my code seems to be returning an empty array when trying to use chrome.cookies.getAll
asynchronously. It could be that I'm using it incorrectly, or that the url
isn't passing through.
chrome.history.onVisited.addListener(function(HistoryItem) {
var cookies = {
start: function(callback) {
this.logCookies(HistoryItem.url,callback);
},
logCookies: function(url,callback) {
chrome.cookies.getAll({
'url': url
}, function(cookie) {
console.log(cookie) //log the cookie
});
}
}
cookies.start(function() {
console.log('getting cookies...')
});
});
I hope this isn't too vague... what I'm trying to do is get all cookies from the currently visited website and log them. (My hope is to delete them in the future, but for now I would like to log each cookie found). Instead, it returns an empty array with the length of 0, and getting cookies...
does not show up in the console. I'm not sure what I did wrong, it seems to me that I did everything right. I'm new to asynchronous coding, so a little help would be appreciated. Thank you!