Last active
March 11, 2024 04:00
-
-
Save titangene/eed5f901b5e0e5e5bf26072c4c67925e to your computer and use it in GitHub Desktop.
copy YouTube subtitles
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
!(() => { | |
const captionElements = document.getElementsByClassName('segment-text style-scope ytd-transcript-segment-renderer'); | |
const caption = [...captionElements] | |
.reduce((result, element) => result + element.innerText + ' ', '') | |
.replace(/[\.]/g, '.\n\n'); | |
const textArea = document.createElement('textarea'); | |
copyText = caption; | |
textArea.value = copyText; | |
document.body.appendChild(textArea); | |
textArea.select(); | |
document.execCommand('Copy'); | |
textArea.remove(); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment