Skip to content

Commit 1aabe15

Browse files
committed
fix the issue where YouTube subtitles could not be fetched and the video summarization feature became unavailable due to the recent introduction of the "pot" parameter by YouTube
1 parent 20e5ae7 commit 1aabe15

File tree

1 file changed

+20
-1
lines changed
  • src/content-script/site-adapters/youtube

1 file changed

+20
-1
lines changed

src/content-script/site-adapters/youtube/index.mjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,26 @@ export default {
4141
let title = docText.substring(docText.indexOf('"title":"') + '"title":"'.length)
4242
title = title.substring(0, title.indexOf('","'))
4343

44-
const subtitleResponse = await fetch(subtitleUrl)
44+
let potokenSource = performance
45+
.getEntriesByType('resource')
46+
.filter((a) => a?.name.includes('/api/timedtext?'))
47+
.pop()
48+
if (!potokenSource) {
49+
//TODO use waitUntil function in refactor version
50+
await new Promise((r) => setTimeout(r, 500))
51+
document.querySelector('button.ytp-subtitles-button.ytp-button').click()
52+
await new Promise((r) => setTimeout(r, 100))
53+
document.querySelector('button.ytp-subtitles-button.ytp-button').click()
54+
}
55+
await new Promise((r) => setTimeout(r, 500))
56+
potokenSource = performance
57+
.getEntriesByType('resource')
58+
.filter((a) => a?.name.includes('/api/timedtext?'))
59+
.pop()
60+
if (!potokenSource) return
61+
const potoken = new URL(potokenSource.name).searchParams.get('pot')
62+
63+
const subtitleResponse = await fetch(`${subtitleUrl}&pot=${potoken}&c=WEB`)
4564
if (!subtitleResponse.ok) return
4665
let subtitleData = await subtitleResponse.text()
4766

0 commit comments

Comments
 (0)