Created
October 21, 2023 16:39
-
-
Save gullinbursti/1eca2c3ff41c532514af5801786a4c75 to your computer and use it in GitHub Desktop.
js page screenshot
This file contains hidden or 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
[...document.querySelectorAll('div,main,body')].forEach((node)=> { | |
node.style.position = 'relative'; | |
node.style.height = 'auto'; | |
node.style.overflowY = 'visible'; | |
}); | |
[...document.querySelectorAll('button')].forEach((node)=> { | |
node.remove(); | |
}); | |
const { default: html2canvas } = await import('https://cdn.skypack.dev/html2canvas'); | |
const canvas = await html2canvas(document.querySelector('main')); | |
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png')); | |
const link = document.createElement('a'); | |
link.target = '_blank'; | |
link.href = URL.createObjectURL(blob); | |
link.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment