Very good !
I must say i was surprised about what you wrote about a content script not being able to access image data. I gave it a try and it seems to work for me, on both Firefox 58.0a1 and Chrome 61.0.3163.100.
Here is my test code:
var imgs = document.querySelectorAll("img");
if(imgs.length>0) {
try {
var img = imgs[0];
var canvas = document.createElement("canvas");
canvas.setAttribute("width",img.width);
canvas.setAttribute("height",img.height);
var context = canvas.getContext("2d");
context.drawImage(img,0,0);
var imgData = context.getImageData(0,0,img.width,img.height);
var data = [];
for(var i=0;i<10;i++)
data.push(imgData.data[i]);
alert("Size "+imgData.data.length+" "+JSON.stringify(data));
} catch(e) {
alert(e.message);
}
}
The script was injected using browser.tabs.executeScript()
.
I haven’t tried former Firefox versions but apparently that security restriction is no longer there.