This repository has been archived by the owner on Oct 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
solution.js
66 lines (65 loc) · 1.81 KB
/
solution.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* 超星刷课脚本
* 更新时间:2018-09-15
* 协议方式:模拟页面操作
* 风险等级:轻微
* @author Jokin
* @version 2.0.1-beta
*/
var right_seletcor = $("div.right#selector");
var courseArray = new Array();
var player;
$(function(){
tips("初始化刷课数据(5s)");
setTimeout("launcher();", 5000);
});
// 启动器
function launcher() {
getAllCourses();
switchCourse();
}
// 获取所有未通过课程
function switchCourse() {
if ( courseArray.length === 0 ){
tips("刷课完成,请刷新查看最终结果", "red");
return false;
}
// 跳转至未刷课程
var _course = courseArray.shift();
var pattern = /[\s\S]+\'(\d+)\'\)/;
var course_id = _course.match(pattern)[1];
var course = $('h4#cur' + course_id);
var course_status = $('h4#cur' + course_id + '>span').eq(1).hasClass('blue');
if (course_status === true) {
tips("跳过已刷课程:" + course_id + " | 剩余课程:" + courseArray.length, 'grey');
switchCourse();
} else {
course.click();
tips("15秒后尝试播放");
setTimeout("simulateWatching()", 15000);
}
}
function simulateWatching() {
tips("播放视频");
player = $("iframe").contents().find("iframe").contents().find('video#video_html5_api')[0];
player.play();
player.muted = true;
listen();
}
function listen() {
player.addEventListener('ended',function(){
tips('切换课程');
switchCourse();
},false);
}
// 获取所有课程
function getAllCourses(){
tips("获取所有课程中");
var data = right_seletcor.html();
var pattern = /getTeacherAjax\('(.+)','(.+)','(.+)'\);/gum;
courseArray = data.match(pattern);
}
// 通知
function tips(text, color="blue"){
console.log("%c【超星刷课】" + text, "color:" + color);
}