chaoxing-download

超星慕课资源下载提取

当前为 2021-03-30 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         chaoxing-download
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  超星慕课资源下载提取
// @author       NL
// @match        https://*.chaoxing.com/mycourse/studentstudy?*
// @grant        none
// ==/UserScript==
let gotoDL = (e,url)=>{console.log(url)
                      window.open(url, "_blank");
                      }
function setDl(){
    //console.log('set dl was called')
var iframes = document.getElementById("iframe").contentWindow.document.querySelectorAll("iframe")
for(let i=0;i<iframes.length;i++){
    if(iframes[i].getAttribute("objectId")==null){
        continue
    }
    let url = "https://cs-ans.chaoxing.com/download/"+iframes[i].getAttribute("objectId")
    iframes[i].previousSibling.innerText = "________________________↓下载课件"
    iframes[i].previousSibling.style.overflow = "visible"
    iframes[i].previousSibling.style.width = "400px"
    iframes[i].previousSibling.addEventListener("click",(e)=>{gotoDL(e,url)},false)
}
}
(function() {
    'use strict';
    var old_text = "";
    console.log("download script running:");
    setTimeout(function (){
        old_text = document.getElementsByTagName("h1")[0].innerHTML;
        document.getElementsByTagName("h1")[0].innerHTML += "--->Waiting";
    },500);
    setTimeout(function(){

        var parent_node = document.getElementsByClassName("goback")[0]
        var bt = document.createElement("button")
        bt.innerHTML = "刷新下载"
        bt.onclick = function(){setDl()}
        parent_node.appendChild(bt)
    },500);
    setTimeout(function(){
        document.getElementsByTagName("h1")[0].innerHTML = old_text
        //setDl()       // DEBUG
        setInterval(setDl,2000)
    },1500);
    // Your code here...
})();