Created
May 20, 2024 15:50
-
-
Save zachmullen/a66b215f5f23bac32bb895970c26e191 to your computer and use it in GitHub Desktop.
Save all canvas contents on the page to PNG files
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
const canvases = document.querySelectorAll('canvas'); | |
for (let i = 0; i < canvases.length; i++) { | |
const canvas = canvases[i]; | |
const link = document.createElement('a'); | |
link.download = `canvas-${i}.png`; | |
link.href = canvas.toDataURL(); | |
link.click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment