-
-
Save Uvacoder/efdfd50d63f736ede48f09b32686db56 to your computer and use it in GitHub Desktop.
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
let $segments = document.querySelector('.ytd-transcript-search-panel-renderer #segments-container') | |
let sections = [] | |
let parts = [] | |
for (let $el of $segments.children) { | |
if ($el.tagName == 'YTD-TRANSCRIPT-SECTION-HEADER-RENDERER') { | |
if (parts.length > 0) { | |
sections.push(parts.join(' ')) | |
parts = [] | |
} | |
sections.push($el.querySelector('#title').innerText) | |
} else { | |
parts.push($el.querySelector('.segment-text').innerText.trim()) | |
} | |
} | |
if (parts.length > 0) { | |
sections.push(parts.join(' ')) | |
} | |
let $link = document.createElement('a') | |
let url = URL.createObjectURL(new Blob([sections.join('\n\n')], {type: "text/plain"})) | |
let title = document.querySelector('#above-the-fold #title')?.innerText ?? 'transcript' | |
$link.setAttribute('href', url) | |
$link.setAttribute('download', `${title}.txt`) | |
$link.click() | |
URL.revokeObjectURL(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment