Created
April 28, 2022 10:01
-
-
Save egorvinogradov/463a8a45f9bd9a92d0b07cfc45a986a5 to your computer and use it in GitHub Desktop.
Copy typed text on https://speechpad.ru
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
(function(){ | |
function hasFinishedTalking(){ | |
let currentText = document.getElementById('copyel').value.trim(); | |
let savedText = window.savedText || ''; | |
if (currentText !== savedText) { | |
window.savedText = currentText; | |
if (!currentText) { | |
return savedText; | |
} | |
} | |
} | |
function copyToClipboard(text) { | |
document.execCommand('copy'); | |
navigator.clipboard.writeText(text).then(function() { | |
console.log('COPIED'); | |
}, function() { | |
console.error('NOT COPIED'); | |
}); | |
} | |
setInterval(() => { | |
let said = hasFinishedTalking(); | |
if (said) { | |
console.log('Said: ', said); | |
window.said = said; | |
copyToClipboard(said); | |
} | |
}, 200); | |
})() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment