Panopto Transcript

Adds a button to copy a full video transcript from Panopto

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==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);
})();