超星尔雅刷课 / 自动阅读脚本 —— js 版

本贴最后更新于 2206 天前,其中的信息可能已经事过境迁

最近选修课很多啊,我们学习的是智慧树的,智慧树的刷课脚本我朋友已经写好了,自己就不想写了,见智慧树刷课 js 脚本。不过其他学校的有的就是超星尔雅的了,我同学一口气选了四门选修=-=,但是没时间刷,所以我给他弄了个 teamviewer ,可以在外面的时候手机远程连接点下一个,但是感觉效率很慢而且老是忘记,所以自己也想写一个刷课脚本,于是才有了这篇博客。

刷课有风险,由于是纯 js 代码,所以我个人觉得我的这个是风险最低的,但是却不敢保证完全没有风险。


免责申明:本脚本仅供技术交流,请勿用于商业及非法用途,如产生法律纠纷与本人无关!使用后产生的一切后果由使用者自行承担,本人概不负责。

分析

首先当然是分析他的网页元素,发现它使用的是 html5 的 video 标签,其中的暂停按钮这些都是有对应的元素的。并且他默认引入力 jquery,所以自己就果断用了 jq。下面是本人测试的一些事件使用。

  • 播放按钮点击 $('.vjs-big-play-button').click()
  • 进度条 class:vjs-play-progress
  • 子页面获取 iframe 里的播放按钮 $('html iframe').contents().find('iframe').contents().find('.vjs-big-play-button').click()
  • 当前课程 class: ncells h4.currents
  • 切换时初始播放 $('html iframe').contents().find('iframe').contents().find('.vjs-poster').click()
  • 总控制器 $('html iframe').contents().find('iframe').contents().find('.vjs-play-control')
  • 播放时,总控制器拥有 vjs-playing 类,暂停时,总控制器有 vjs-paused

成品代码

/** * author: EchoCow * website: https://www.echocow.cn * description: 自动播放,下一集,无视答题窗口,刷超星尔雅的课程 * use-method: 打开超星尔雅播放课程界面 按F12 -> Console -> 粘贴本代码 ->按回车键 * use-method: 视频目录上方出现 Welcome to use EchoGet! 以及 status,点击 start 按钮开启脚本。 */ function start() { echo_flag = !echo_flag; if (echo_flag) { echo_tip.text("stop"); echo_status.text("Status: EchoGet start..."); echo_get(); // 1分钟检测一次,1 min = 60000 ms echo_id = setInterval(echo_get,2000); console.log("EchoGet start..."); } else { echo_tip.text("start"); echo_status.text("Status: EchoGet stop..."); window.clearInterval(echo_id); console.log("EchoGet stop..."); } } function echo_get() { console.log((++echo_times) + " times run..."); if (echo_times % 200 == 0) { console.clear(); } // 获取播放器 var echo_video = $('html iframe').contents().find('iframe').contents(); // 获取当前播放的 var echo_now = $('.ncells h4.currents'); // 获取当前播放的父节点以方便获取下一个视频 var echo_now_parent = echo_now.parent().parent().next().length === 0 ? echo_now.parents(".cells") : echo_now.parents(".ncells"); // 获取下一个视频链接 var echo_next = echo_now_parent.next().find('h4 a span'); // 获取进度条 var echo_progress = echo_video.find(".vjs-play-progress").width() / echo_video.find(".vjs-play-progress").parent().width(); // 获取总控制器 var echo_control = echo_video.find('.vjs-play-control'); // 是否完成 var echo_start_flag = !echo_control.hasClass('vjs-playing') && !echo_control.hasClass('vjs-paused') && echo_progress == 0; // 进度大于 95% 为完成 if (echo_progress > 0.95) { if (echo_next.length === 0) { echo_next = echo_now_parent.parent().next().children('.ncells').first().find('h4 > a > span') } console.log("Now class is finished:" + echo_now.text().replace(/\s+/g, "")); console.log("Next class is:" + echo_next.text().replace(/\s+/g, "")); // 点击下一个 echo_next.click(); // 给他三秒的加载时间再点击。 setTimeout(function () { $("span[title='视频']").click() $('html iframe').contents().find('iframe').contents().find('.vjs-big-play-button').click(); }, 3000); } else { // 未完成,检测播放状态,如果暂停,就让他播放 if (echo_control.hasClass('vjs-paused') || echo_start_flag) { $('html iframe').contents().find('iframe').contents().find('.vjs-big-play-button').click(); } } } var echo_box = $("<div style='background: wheat;padding: 20px;'><h4 style='margin: 0;'>Welcome to use EchoGet! By: <u><i><a style='color: coral' href='https://www.echocow.cn' target='_blank'>EchoCow</a></i></u></h4><h4 id='echo_status' style='margin: 0;'>Status: EchoGet stop...</h4><h4 style='margin: 0;'>Now, you can choose <button id='echo_tip' onclick='start()'>start</button></h4></div>"); $('.right').prepend(echo_box); var echo_flag = false; var echo_id; var echo_times = 0; var echo_tip = $('#echo_tip'); var echo_status = $('#echo_status'); console.clear(); console.log("The EchoGet is OK!Please click start...");

自动阅读

var echo_height = $(document).height()  ; var echo_scroll = 0; var echo_index = 0; function echo_play(){     $('iframe').each(function(e){         $(this).contents().find('.vjs-big-play-button').click();     }) } var echo_time = setInterval(function() {     console.log((echo_index++) + " times use...Now is " + echo_scroll);     echo_scroll += Math.random()*30;     $(window).scrollTop(echo_scroll);       if(echo_scroll >= echo_height ){         echo_play();         console.log("Loading more...");         $("#loadbutton").click();         echo_height = $(document).height()  ;         console.log("New height is echo_height");         setTimeout(function(){             if($("#loadbutton").size() == 0){                 console.log("Get Successed! Use " + echo_index + " times!");                 clearInterval(echo_time);              }         },5000);     } }, 1000);
  • JavaScript

    JavaScript 一种动态类型、弱类型、基于原型的直译式脚本语言,内置支持类型。它的解释器被称为 JavaScript 引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在 HTML 网页上使用,用来给 HTML 网页增加动态功能。

    730 引用 • 1282 回帖 • 5 关注
  • jQuery

    jQuery 是一套跨浏览器的 JavaScript 库,强化 HTML 与 JavaScript 之间的操作。由 John Resig 在 2006 年 1 月的 BarCamp NYC 上释出第一个版本。全球约有 28% 的网站使用 jQuery,是非常受欢迎的 JavaScript 库。

    63 引用 • 134 回帖 • 735 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...