Skip to content

Instantly share code, notes, and snippets.

@sanbei011
Created May 13, 2024 14:53
Show Gist options
  • Save sanbei011/cac6674c6c3abd4ab4ea225a6f57b868 to your computer and use it in GitHub Desktop.
Save sanbei011/cac6674c6c3abd4ab4ea225a6f57b868 to your computer and use it in GitHub Desktop.
入党积极分子刷课
// ==UserScript==
// @name 农大叛逆份子
// @description CAU入党积极分子
// @author sanbei101
// @match http://202.205.91.77:8090/*
// @match http://ncst.dangqipiaopiao.com/jjfz/*
// @match http://ncst.dangqipiaopiao.com/exam/*
// @grant unsafeWindow
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @require https://cdn.bootcdn.net/ajax/libs/jquery/2.0.0/jquery.js
// @icon http://www.gov.cn/ztzl/17da/183d03632724084a01bb02.jpg
// @version 0.0.1.20240507141357
// @namespace https://greasyfork.org/users/1225751
// @downloadURL https://update.greasyfork.org/scripts/494309/%E5%86%9C%E5%A4%A7%E5%8F%9B%E9%80%86%E5%88%86%E5%AD%90.user.js
// @updateURL https://update.greasyfork.org/scripts/494309/%E5%86%9C%E5%A4%A7%E5%8F%9B%E9%80%86%E5%88%86%E5%AD%90.meta.js
// ==/UserScript==
let settings = {
video: 1, // 视频弹窗自动关闭,默认开启
jump: 1, // 自动切换下一个视频任务点,默认开启(需要开启视频弹窗自动关闭)
back: 1, // 視頻播放完成自動回到章節列表,默认关闭(需要开启自动切换到下一个任务点)
class: 1, // 自动切换到未播放的章节,默认开启(需要开启視頻播放完成自動回到章節列表)
},
_self = unsafeWindow,
url = location.pathname,
classLists = [],
videoLists = [];
let $$ = top.jQuery;
if (url == "/jjfz/lesson/video" && settings.class) {
if (GM_getValue("dont_note")) {
let passNum = 0;
let cl = setInterval(() => {
getClassList();
passNum = $$(".lesson_pass").length;
console.log(passNum)
if (classLists.length) {
jumpToVideoFromClass(passNum)
}
if (classLists.length) clearInterval(cl);
}, 1000);
} else {
video_note();
}
}
if (url.indexOf("play") != -1&& settings.video) {
playVideo();
let nextVideoFlag = false,
nextClassFlag = false;
console.log("这是视频播放方法")
let vp = setInterval(() => {
if (!videoLists.length) {
getVideoList();
}
nextVideoFlag = closeAlert();
if (settings.jump) {
nextClassFlag = jumpToVideo(videoLists);
if (nextVideoFlag) nextClassFlag = nextVideo(videoLists);
}
if (settings.back) {
if (nextClassFlag) goBack();
}
}, 1000)
}
function getClassList() {
let classList = []
if ($$(".l_list_right")) {
$$(".l_list_right").each((ind, ele) => {
if ($$(ele).find("div .r_read").text() == " 必 修 ") {
classList.push($$(ele).find("h2 a"))
}
})
}
classLists = classList;
}
function getVideoList() {
if ($$(".video_lists li").length) {
console.log("当前视频" + $$(".video_red1").text())
videoLists = $$(".video_lists li");
}
}
function jumpToVideoFromClass(passNum) {
if (passNum != classLists.length) {
$$(classLists[passNum]).attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
}
}
function closeAlert() {
if ($$(".public_submit").length) {
//console.log("视频数量" + $$(".video_lists li"))
let text = $$(".public_text").text();
if (text.indexOf("当前视频播放完毕") >= 0) {
return true;
} else if (text.indexOf("该课程视频你上次观看到") >= 0) {
$$(".public_cancel").attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
return false;
} else {
$$(".public_submit").attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
return false;
}
}
}
function nextVideo(videoList) {
let index = $$(videoList).index($$(".video_red1"));
if (videoList[index + 1]) {
$$(videoList[index + 1]).children("a").attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
return false;
} else {
return true;
}
}
function jumpToVideo(videoList) {
if ($$(".video_red1").find("a").attr("style") == "width:70%;color:red") {
let index = $$(videoList).index($$(".video_red1"));
if (videoList[index + 1]) {
$$(videoList[index + 1]).children("a").attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
} else {
return true;
}
}
}
function goBack() {
$$(".video_goback").attr('id', 'aRemoveAllTxt');
document.getElementById("aRemoveAllTxt").click();
}
function playVideo() {
_self.studyTime = function () {
var diff_time = 5000;
$.ajax({
type: "POST",
cache: false,
dataType: "json",
url: "/jjfz/lesson/study_time",
data: {
rid: "630089",
study_time: diff_time,
_xsrf: $(":input[name='_xsrf']").val()
},
success: function () {
}
});
flag = setTimeout("studyTime()", diff_time);
}
_self.player.on('pause', function (event) {
if ($$(".public_submit").length) {
} else _self.player.play();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment