Last active
November 1, 2021 19:19
-
-
Save ahmedazhar05/63ce1845ebc653aef774d5add4b61076 to your computer and use it in GitHub Desktop.
Copy modified image from whatsapp-web's pre-send image editing canvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function() { | |
let cvs = document.querySelectorAll('.konvajs-content > canvas'); | |
let backup = cvs[0].toDataURL("image/png"); | |
let img = document.createElement("IMG"); | |
img.onload = () => { | |
cvs[0].getContext("2d").drawImage(img, 0, 0); | |
cvs[0].toBlob(blob => { | |
navigator.clipboard.write([new ClipboardItem({ | |
"image/png": blob | |
})]); | |
alert("Image has been copied to Clipboard!"); | |
}); | |
img = document.createElement("IMG"); | |
img.onload = () => cvs[0].getContext("2d").drawImage(img, 0, 0); | |
img.src = backup; | |
}; | |
img.src = cvs[1].toDataURL("image/png"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment