While attempting to write my own script, I found that there are many websites which offer YouTube summaries, which are probably an easier solution. For example (not affiliated) https://www.easemate.ai/video-summary It even allows you to ask questions about the transcript.
I also found a Python library for fetching YouTube video transcripts, but some issue mentioned that they got banned, so out of caution, I implemented my summary script as a JavaScript bookmarklet instead. It will probably break on the next YouTube update, so I am not sure how useful it is. Also, you have to set your own API key (and maybe URL). I used Groq (not to be confused with Grok), because it is free and very fast.
javascript:(function(){
var GROQ_API_KEY = "YOUR_API_KEY_HERE";
var btn = [...document.querySelectorAll('button')].find(b => b.textContent.trim() === 'Show transcript');
btn.click();
function checkTranscriptAvailable(){
var transcript = document.querySelector('[target-id="engagement-panel-searchable-transcript"]').innerText;
console.log("transcript:", transcript.slice(0, 50));
var length = transcript.replace(/\s/g, '').length;
if (length > 100){
fetch("https://api.groq.com/openai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer " + GROQ_API_KEY,
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "openai/gpt-oss-120b",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Briefly summarize this transcript:\n\n" + transcript,
},
]
}
]
})
})
.then(res => res.json())
.then(data => alert(data.choices[0].message.content))
.catch(err => alert(err));
}else{
setTimeout(checkTranscriptAvailable, 1000);
}
};
checkTranscriptAvailable();
})();