Skip to content

Instantly share code, notes, and snippets.

@egorvinogradov
Created April 28, 2022 10:01
Show Gist options
  • Save egorvinogradov/463a8a45f9bd9a92d0b07cfc45a986a5 to your computer and use it in GitHub Desktop.
Save egorvinogradov/463a8a45f9bd9a92d0b07cfc45a986a5 to your computer and use it in GitHub Desktop.
Copy typed text on https://speechpad.ru
(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