I am new to JavaScript. Last few days I make extension for Chrome, which takes screenshots of all tabs and pushes this data to clipboard. Each image weighs a lot and so I decided to compress them. But it doesn't work. Can anyone know what the problem is?
function copyToClipBoard(dataImage){
document.body.appendChild(input);
input.style.position = 'fixed';
input.style.opacity = 0;
var newImage = new Image();
newImage.src = dataImage;
console.log (newImage);
var canvas = document.createElement('canvas');
var ctx = canvas.getContext("2d").drawImage(newImage, 0, 0);
input.value = canvas.toDataURL('image/jpeg', 0.1);
console.log(input.value);
input.select();
document.execCommand('Copy');
document.body.removeChild(input);
}