Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created December 2, 2022 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubgit/b46300834903442ccf19272d1136eb13 to your computer and use it in GitHub Desktop.
Save hubgit/b46300834903442ccf19272d1136eb13 to your computer and use it in GitHub Desktop.
[...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