I'm a beginner in js and trying to code a plugin using "downloads"-API. Sadly I can't find out what's wrong. The console gives the following Error: " main.js:6 Uncaught TypeError: Cannot read properties of undefined (reading 'onCreated') "
Manifest:
{
"manifest_version":3,
"version":"1.0",
"name":"Test",
"content_scripts":[
{
"matches":["<all_urls>"],
"js":["main.js"],
"permissions":["downloads"]
}
]
}
main.js :
function handleCreated(item) {
console.log(item);
}
chrome.downloads.onCreated.addListener(handleCreated);
The error occurs directly after the DOM is loaded, so it does not even recognize that it should wait until a download has started. Any idea?
thx a lot!