智慧职教 | 职教云 —— 课件下载

仅提供智慧职教课件下载

目前为 2021-12-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         智慧职教 | 职教云 —— 课件下载
// @namespace    https://gf.qytechs.cn/zh-CN/users/856720
// @version      0.1
// @description  仅提供智慧职教课件下载
// @license      GPL License
// @author       a我还是少年a
// @match        https://zjy2.icve.com.cn/common/directory/directory.html?*
// @match        http://zjy2.icve.com.cn/common/directory/directory.html?*
// @icon         https://zjy2.icve.com.cn/favicon.ico
// @grant        none
// ==/UserScript==

(function() {

    //获取课件网页URL信息
    function getQueryVariable(variable){
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
    }

    //获取具体参数
    var courseOpenId = getQueryVariable("courseOpenId");
    var openClassId = getQueryVariable("openClassId");
    var cellId = getQueryVariable("cellId");
    var flag = getQueryVariable("flag");
    var moduleId = getQueryVariable("moduleId");

    //创建ajax对象
    var xhr = new XMLHttpRequest();
    //初始化设置类型和url
    xhr.open('POST','https://zjy2.icve.com.cn/api/common/Directory/viewDirectory');
    //POST请求ajax,必须设置请求头
    xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded')
    //发送请求,POST参数
    xhr.send('courseOpenId='+ courseOpenId +'&openClassId='+ openClassId +'&cellId='+ cellId +'&flag='+ flag +'&moduleId='+moduleId);
    //事件绑定
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4){
            if(xhr.status >= 200 && xhr.status < 300){

                //将服务器返回结果以JSON方式呈现
                var txt = JSON.parse(xhr.response);
                //在控制台输出课件下载地址,用于调试,可删除
                console.log(txt.downLoadUrl);
                //定义一个url,赋值为请求到的课件下载地址
                var url = txt.downLoadUrl;

                //延迟一秒执行
                setTimeout(function(){
                    //改变原本的class名称,使得图标显示
                    document.getElementById("download").className='admin';
                    //将原本的空链接改变为获取到的课件地址
                    document.getElementById("down_resource").setAttribute('href',url);
                },1000);

            }
        }
    }

    'use strict';

    // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址