Skip to content

Instantly share code, notes, and snippets.

@titangene
Last active March 11, 2024 04:00
Show Gist options
  • Save titangene/eed5f901b5e0e5e5bf26072c4c67925e to your computer and use it in GitHub Desktop.
Save titangene/eed5f901b5e0e5e5bf26072c4c67925e to your computer and use it in GitHub Desktop.
copy YouTube subtitles
!(() => {
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