Skip to content

Instantly share code, notes, and snippets.

@DragoonAethis
Created June 26, 2022 16:06
Show Gist options
  • Save DragoonAethis/3bf4da7e18258b81f6fe675e6a3691f5 to your computer and use it in GitHub Desktop.
Save DragoonAethis/3bf4da7e18258b81f6fe675e6a3691f5 to your computer and use it in GitHub Desktop.
On YouTube, open the transcription panel and run this bookmarklet to copy the transcription to your clipboard without timestamps.
javascript: (() => {
const fragments = [];
const elems = document.getElementsByClassName("ytd-transcript-segment-renderer");
if (elems.length === 0) {
alert("No transcript elements found - are you sure the transcription panel is open?");
return;
}
for (const elem of elems) {
/* Want timestamps? Remove .slice(1) here: */
var frags = elem.innerText.split('\n').slice(1);
fragments.push(...frags);
}
navigator.clipboard.writeText(fragments.join('\n')).then(
function() {},
function() { alert("Cannot access the clipboard - click anywhere on the page and try again."); }
);
})();
/* Create a new bookmark and set its URL to one of the javascript:... lines below. */
/* No timestamps: */
javascript:(() => {const fragments = [];const elems = document.getElementsByClassName("ytd-transcript-segment-renderer");if (elems.length === 0) {alert("No transcript elements found - are you sure the transcription panel is open?");return;}for (const elem of elems) {var frags = elem.innerText.split('\n').slice(1);fragments.push(...frags);}navigator.clipboard.writeText(fragments.join('\n')).then(function() {},function() { alert("Cannot access the clipboard - click anywhere on the page and try again."); });})();
/* With timestamps: */
javascript:(() => {const fragments = [];const elems = document.getElementsByClassName("ytd-transcript-segment-renderer");if (elems.length === 0) {alert("No transcript elements found - are you sure the transcription panel is open?");return;}for (const elem of elems) {var frags = elem.innerText.split('\n');fragments.push(...frags);}navigator.clipboard.writeText(fragments.join('\n')).then(function() {},function() { alert("Cannot access the clipboard - click anywhere on the page and try again."); });})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment