Last active
September 7, 2025 08:22
-
-
Save LewisGet/03c34c2d9ea5fdfcba70435782cad054 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 下載 youtube 字幕按鈕 | |
| // 建立一個下載字幕的按鈕 | |
| const downloadButton = document.createElement('a'); | |
| var yt = ytInitialPlayerResponse['captions']; | |
| // 字幕語言列表物件,這物件需讀取過,才會將字幕 url 讀取,通過 token | |
| // yt.playerCaptionsTracklistRenderer.captionTracks; | |
| downloadButton.setAttribute('href', yt.playerCaptionsTracklistRenderer.captionTracks[0].baseUrl); | |
| downloadButton.setAttribute('download', `subtitles.srt`); | |
| downloadButton.innerText = 'Download Subtitles'; | |
| downloadButton.style.fontSize = '16px'; | |
| downloadButton.style.padding = '10px'; | |
| downloadButton.style.backgroundColor = 'blue'; | |
| downloadButton.style.color = 'white'; | |
| downloadButton.style.borderRadius = '5px'; | |
| downloadButton.style.position = 'fixed'; | |
| downloadButton.style.top = '50%'; | |
| downloadButton.style.left = '50%'; | |
| downloadButton.style.transform = 'translate(-50%, -50%)'; | |
| // 將按鈕加入到網頁上 | |
| document.body.appendChild(downloadButton); | |
| downloadButton.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment