我正试图从谷歌chrome扩展程序下载一张图片。下载方式如下:
const image = new Image();
function loadImage() {
context.clearRect(0, 0, widthGraph, heightGraph);
context.drawImage(image, 0, 0, widthGraph, heightGraph);
canvas.toBlob((blob) => {
saveAs(blob, 'D3 vis exported to PNG.png');
});
}
image.addEventListener('load', loadImage, false);
image.src = imgsrc;
但是
onload
甚至没有被触发。
如果你想查看完整的代码,它们就在这里:
https://github.com/maifeeulasad/React-Sight/blob/download-feature/extension/frontend/drawChart.js#L362-L378
我的清单是这样的:
...
"background": {
"scripts": [
"background.js"
]
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
}],
"content_security_policy": "script-src 'self'; object-src 'self'",
"permissions": [
"tabs",
"activeTab",
"<all_urls>"
],
...
有人能帮我调试出了什么问题吗?