Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save subtleGradient/2a2fa75511fd410ae01159803fa76eb4 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/2a2fa75511fd410ae01159803fa76eb4 to your computer and use it in GitHub Desktop.
JS Bookmarklet to Get the text content of any YouTube video that has a transcript!
javascript: void (()=>{
let text = null;
try {
text = document
.querySelector("ytd-transcript-renderer")
.__data
.data
.body
.transcriptBodyRenderer
.cueGroups
.map(cueGroup => cueGroup
.transcriptCueGroupRenderer
.cues
.map(cue => cue
.transcriptCueRenderer
.cue
.runs
.map(run => run.text)
)
).flat().flat()
.join('\n')
;
} catch (e) {
console.error(e);
}
if (text == null) {
alert("Please open the transcript thing by clicking the triple-dot button next to the like and other buttons first, then do this again!");
} else if (text.length < 2000) {
prompt("This is the text", text);
} else {
window.TEXT = text;
console.log({text});
console.log(`Type copy(TEXT) to get the transcript text`);
alert("Text is too long to use a prompt, open the console to get it.");
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment