LectureTube Downloader - tuwien.ac.at

Adds a simple Download button to save LectureTube videos with one click

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        LectureTube Downloader - tuwien.ac.at
// @namespace   Violentmonkey Scripts
// @match       https://oc-presentation.ltcc.tuwien.ac.at/engage/theodul/ui/core.html
// @grant       none
// @version     1.0
// @author      -
// @description Adds a simple Download button to save LectureTube videos with one click
// @require     https://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==

$(document).ready(function () {
  const timer = setInterval(function () {
    const videoRefs = document.getElementsByTagName('video');
    const controlButtons = document.getElementById('dropdownControlsButtons');
    if (videoRefs.length > 0 && controlButtons) {
      clearInterval(timer);
      const videoSrc = videoRefs[0].currentSrc;
      const videoType = videoSrc.substring(videoSrc.lastIndexOf('.'), videoSrc.length);
      const videoTitle = document.getElementById('engage_basic_description_title').innerHTML + videoType;
      controlButtons.appendChild(createDownloadButton(videoSrc, videoTitle));
    }
  }, 5000);
});

function createDownloadButton(src, title) {
  const button = document.createElement('a');
  button.setAttribute('class', 'btn btn-default');
  button.setAttribute('href', src);
  button.setAttribute('type', 'button');
  button.setAttribute('download', title);
  button.innerHTML = 'Download';
  return button;
}