Panopto Transcript

Adds a button to copy a full video transcript from Panopto

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Panopto Transcript
// @namespace    http://tampermonkey.net/
// @version      2024-10-01
// @description  Adds a button to copy a full video transcript from Panopto
// @author       ioc
// @match        https://*.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=panopto.eu
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const btn = document.createElement("button");
    btn.innerHTML = "Copy transcript";
    btn.onclick = function(event) {
        event.preventDefault();

        function getElementByXpath(path) {
            return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
        }

        const textArr = [];
        const largeSet = document.getElementsByClassName("index-event");

        for (let i=0; i<largeSet.length; i++) {
            const e = largeSet[i];
            try {
                if (e.id.toLowerCase().includes("transcript")) {
                    textArr.push(e.children[1].children[1].children[0].innerText);
                }
            } catch (error) {}
        }

        let res = textArr.join(" ");
        res = res.replaceAll(". ", ".\n");

        const type = "text/plain";
        const blob = new Blob([res], { type });
        const data = [new ClipboardItem({ [type]: blob })];
        window.navigator.clipboard.write(data);
    }
    document.getElementById("eventTabControl").appendChild(btn);
})();