Print All Panopto Captions

Adds a button to download all captions on the left pane when viewing a panopto video.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Print All Panopto Captions
// @locale Eng
// @description Adds a button to download all captions on the left pane when viewing a panopto video.
// @version  1.0
// @grant    none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js 
// @match https://*.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=*
// @namespace https://greasyfork.org/users/170988
// ==/UserScript==

function download(filename, text) {
  var element = document.createElement('a');
  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);
  element.style.display = 'none';
  document.body.appendChild(element);
  element.click();
  document.body.removeChild(element);
}

let button = '<div id="downloadCaptionsTabHeader" class="event-tab-header"><span class="text">Download Captions</span></div>';

$('#transcriptTabHeader').after(button);

$('#downloadCaptionsTabHeader').click(function() {
  
  let allText = "";
  
  for (element of document.getElementsByClassName('index-event')) {
    allText += element.children[1].children[0].children[0].innerHTML + "\n";
  }
  
  //console.log(document.getElementsByClassName('index-event')[0].children[1].children[0].children[0].innerHTML);
  
	download("captions-for_"+$(document).find("title").text().replaceAll(" ", "-")+'.txt', allText.replaceAll("<br>", " "));
});