Skip to content

Instantly share code, notes, and snippets.

@ashnel3
Created October 7, 2019 06:30
Show Gist options
  • Save ashnel3/074ab2f799dce31a5098ee37df87f72e to your computer and use it in GitHub Desktop.
Save ashnel3/074ab2f799dce31a5098ee37df87f72e to your computer and use it in GitHub Desktop.
aberoth-screenshot
/* aberoth-screenshot
* Adds a screenshot button to Aberoth!
*/
function screenshot () {
const data = document.getElementById('screen').toDataURL() // Screenshot image
const a = document.createElement('a')
a.download = 'screenshot.png' // Output file name
a.href = data
a.style.visibility = 'hidden'
a.click() // Download file
a.remove() // Remove link
}
(() => {
const button = document.createElement('a') // Screenshot button
button.innerHTML = 'screenshot' // Button text
button.onclick = screenshot
// Button CSS
button.style = `
position: absolute;
top: 16px;
right: 16px;
cursor: pointer;
`
document.body.appendChild(button) // Append button
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment