Greasy Fork

来自缓存

Greasy Fork is available in English.

USTC网课下载

展示USTC网课回放的直链地址

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         USTC网课下载
// @namespace    https://www.bb.ustc.edu.cn/
// @version      0.5
// @description  展示USTC网课回放的直链地址
// @author       398
// @match        *://www.eeo.cn/*
// @grant        GM_addStyle
// @run-at      document-end
// ==/UserScript==

// 观测对象
let observer;

// 创建可用标签
function createOne() {
    const path_href = document.createElement('a')
    path_href.setAttribute('id', 'download-href');
    document.getElementById('lesson-time').appendChild(path_href);
    return path_href
}

// 回调
function callBack(mutate) {
    let target
    try{target = mutate[0].target} catch (e) {return}
    let href = document.getElementById('download-href')
    href = (href === null || href === undefined)? createOne(): href
    href.textContent = '下载链接:' + target.src;
    href.href = target.src
}

// 立即执行
(function () {
    // 添加样式
    GM_addStyle(`#download-href{color: white; cursor: pointer;} #download-href:hover {color: #29875a;}`)

    // classin 基于 vue 搭建 SPA 项目,会动态刷新页面,采用监听器监听 video 标签变化。
    const playerNode = document.getElementById('player_html5_api')
    const config = {
            attributes: true,
            attributeFilter: ['src']
    }
    observer = new MutationObserver(callBack)
    observer.observe(playerNode, config)
})()