forked from LinHeLurking/Say-No-to-Stupid-Mooc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
good_bye_mooc.user.js
87 lines (77 loc) · 3.79 KB
/
good_bye_mooc.user.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// ==UserScript==
// @name Fuck the stupid mooc
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 国科大慕课学习,鼠标离开界面不会暂停,且不用在视频中答题,还会自动翻页刷下一章,遇到小测会卡住
// @author LinHe
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.4.0/jquery.min.js
// @match http://mooc1.ecourse.ucas.ac.cn/mycourse/*
// @grant none
// ==/UserScript==
/* global $ */
(function () {
'use strict';
const replayVideo = function () {
const playButton = $("#video > div.vjs-control-bar > button.vjs-play-control.vjs-control.vjs-button.vjs-paused", $("iframe").contents().find("iframe").contents()[0])[0];
if (playButton) {
playButton.click();
}
};
$("document").ready(function () {
console.log("Waiting for loading...");
// alert("Script running. If it does not work, it is perhaps because Chrome diables autoplay of videos. If you do not know how to solve it, I recommend you switch to Firefox and enables autoplay in the setting.");
setTimeout(async function () {
const mainFrame = $("iframe");
if (mainFrame) {
while (true) {
const isQuiz = $("#mainid > h1").text().toLowerCase().includes("quiz");
if (!isQuiz) {
const frames = $("iframe").contents().find("iframe").contents();
if (frames) {
const video = frames[0];
const docs = frames.slice(1);
$(".vjs-big-play-button", video).click();
window.setInterval(replayVideo, 200);
for (let index = 0; index < docs.length; index++) {
const doc = docs[index];
const mask = $("#maskLayer", doc);
mask.click();
}
} else {
console.log("ERROR: cannot find video and document");
}
// wait until video finishes.
while (true) {
let play2x = $("li.vjs-menu-item",$("iframe").contents().find("iframe").contents()[0])[0];
if (!play2x.classList.contains("vjs-selected")) {
console.log("click 2x");
play2x.click();
}
console.log("Checking if it's finished.");
var flag = true;
const icons = $(".ans-attach-ct", $("iframe").contents());
// console.log(icons);
for (let index = 0; index < icons.length; index++) {
const icon = icons[index];
flag = flag && icon.className.includes("finished");
}
if (flag) {
console.log("It's finished.");
break;
}
await new Promise(r => setTimeout(r, 15000));
}
window.clearInterval(replayVideo);
}
// click next-button
console.log("Next chapter");
WAY.box.show();
$(".bluebtn02")[0].click();
await new Promise(r => setTimeout(r, 4000));
}
} else {
console.log("ERROR: cannot find main frame from left");
}
}, 4000);
});
})();