Created
October 7, 2019 06:30
-
-
Save ashnel3/074ab2f799dce31a5098ee37df87f72e to your computer and use it in GitHub Desktop.
aberoth-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
/* 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