Last active
February 16, 2022 20:17
-
-
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!
This file contains hidden or 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
| 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