Created
January 20, 2020 16:30
-
-
Save subtleGradient/c5aabe1e0d44d1c912b17707836e6e45 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
javascript: (async () => { | |
const TOP = window.opener || window.top; | |
const document = TOP.document; | |
function nextFrame() { | |
return new Promise(done => { | |
requestAnimationFrame(done); | |
}); | |
} | |
const clickOpenTranscript = () => | |
[...document.querySelectorAll("ytd-menu-service-item-renderer")] | |
.filter(it => it.textContent.includes("Open transcript")) | |
.map(b => b.click()).length > 0; | |
const clickOpenMenu = () => | |
[...document.querySelectorAll('[aria-label="More actions"]')].forEach(b => | |
b.click() | |
); | |
async function turnOnTranscript() { | |
if (!clickOpenTranscript()) { | |
clickOpenMenu(); | |
await nextFrame(); | |
clickOpenTranscript(); | |
} | |
} | |
try { | |
await turnOnTranscript(); | |
} catch (e) { | |
console.error(e); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment