// ==UserScript== // @name 云班课高效助手 // @namespace http://tampermonkey.net/ // @version 1.22 // @description 添加下载按钮,可以按栏缩小范围进行模拟批量点击资源,批量下载资源,提高效率。【基于其他脚本修改(@name 蓝墨云班课(Moso Tech)资源下载;@author xfl03)。】【注意:执行完毕后需刷新页面】【只是出于个人原因开发,只做了chrome适配,其他浏览器可用,但具体操作会有一点不同】 // @author bellamy.n.h // @match https://www.mosoteach.cn/web/index.php* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; /** * 睡眠函数 * @param numberMillis -- 要睡眠的毫秒数 */ function sleep(numberMillis) { var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true) { now = new Date(); if (now.getTime() > exitTime) return; } } /** *文件下载函数 */ function download(name, href) { var a = document.createElement("a"), //创建a标签 e = document.createEvent("MouseEvents"); //创建鼠标事件对象 e.initEvent("click", false, false); //初始化事件对象 a.href = href; //设置下载地址 a.download = name; //设置下载文件名 a.dispatchEvent(e); //给指定的元素,执行事件click事件 } // css const styleTag = ` `; $(styleTag).appendTo('head'); //为每个资源添加下载按钮 $(".res-row-open-enable").each(function() { if ($(this).find(".download-res-button").length > 0) return;//如果已经存在下载按钮(例如mp3),则不再添加 $(this).find("ul").html('