Last active
February 22, 2024 15:53
-
-
Save kamiazya/da0aeff05063af4bda26da1bf81f5fb6 to your computer and use it in GitHub Desktop.
画面をスクショするブックマークレット
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 () { | |
const src = 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js'; | |
const script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = src; | |
script.onload = () => { | |
html2canvas(document.body, { | |
onrendered: (canvas) => { | |
const imgageData = canvas.toDataURL('image/png'); | |
const el = document.createElement('a'); | |
el.setAttribute('href', imgageData.replace(/^data:image\/png/, 'data:application/octet-stream')); | |
el.setAttribute('download', 'screen.png'); | |
el.style.display = 'none'; | |
document.body.appendChild(el); | |
el.click(); | |
document.body.removeChild(el); | |
} | |
}); | |
}; | |
document.body.appendChild(script); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment