Sharepoint Video Transcript Downloader

Download transcripts of SharePoint Stream videos with the download button disabled

2025-11-24 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Sharepoint Video Transcript Downloader
// @namespace   Violentmonkey Scripts
// @match       *://*.sharepoint.com/*/stream.aspx*
// @grant       none
// @version     1.0
// @author      CyrilSLi
// @description Download transcripts of SharePoint Stream videos with the download button disabled
// @license     MIT
// ==/UserScript==

var mediaData, transcriptData;
function getData(callback) {
    if (!mediaData || !transcriptData) {
        const infoUrl = new URL(g_fileInfo[".spItemUrl"].replace("/_api/v2.0/", "/_api/v2.1/"));
        infoUrl.search = "?select=media%2Ftranscripts%2CaudioTracks&%24expand=media%2Ftranscripts%2Cmedia%2FaudioTracks";
        fetch(infoUrl.toString()).then((res) => res.json()).then((media) => {
            mediaData = media;
            infoUrl.pathname += `/media/transcripts/${mediaData.media.transcripts[0].id}/streamContent`;
            infoUrl.search = "?format=json&applyhighlights=false&applymediaedits=false";
            fetch(infoUrl.toString()).then((res) => res.json()).then((transcript) => {
                transcriptData = transcript;
                callback();
            });
        });
    } else {
        callback();
    }
}

const observer = new MutationObserver(() => {
    const disabledBtn = document.querySelector("button#downloadTranscript.is-disabled");
    if (disabledBtn) {
        const textBtn = document.createElement("button");
        textBtn.className = "sp-Stream-command-bar-far-buttons";
        textBtn.style.cssText = "background-color: white; cursor: pointer;";
        textBtn.innerHTML = '<span class="ms-Button-label" style="color: black;">Download Text</span>';
        const vttBtn = textBtn.cloneNode(true);
        vttBtn.children[0].innerText = "Download VTT";
        textBtn.addEventListener("click", () => getData(() => {
            const entries = [];
            transcriptData.entries.forEach((e) => entries.push(`${e.startOffset.split(".")[0]}  ${e.speakerDisplayName}\n${e.text}\n`));
            const link = document.createElement("a");
            link.href = URL.createObjectURL(new Blob([entries.join("\n")], { type: "text/plain" }));
            link.download = mediaData.media.transcripts[0].displayName.replace(/\.[^/.]+$/, "") + ".txt";
            link.click();
        }));
        vttBtn.addEventListener("click", () => getData(() => {
            window.open(mediaData.media.transcripts[0].temporaryDownloadUrl, "_blank");
        }));
        disabledBtn.parentNode.replaceChild(vttBtn, disabledBtn);
        vttBtn.parentNode.insertBefore(textBtn, vttBtn);
    }
    let disabledTooltip = document.querySelector("div#transcriptDownloadDisableTooltip--tooltip");
    if (disabledTooltip) {
        while (!disabledTooltip.classList.contains("ms-Tooltip")) {
            disabledTooltip = disabledTooltip.parentNode;
        }
        disabledTooltip.remove();
    }
});
observer.observe(document.body, {
    attributes: false,
    childList: true,
    characterData: false,
    subtree: true
});