首页 HTML/css/Js正文

西南大学刷党课脚本

欲儿 HTML/css/Js 2022-06-01 585 0

名称:Swu党课刷刷刷

功能简介:

1.本次脚本可以一次刷如下图的内容

image.png

2.点击开始学习后,人就可以离开电脑了。自动刷完该节课的所有必修(必修)视频,刷完后会出现如图提示

image.png


使用方法:(以Firefox浏览器为例子示范)

配置方法:

  1. 打开Firefox,安装扩展Tapermonkey

  2. 打开Firefox的设置

    将阻止弹出式窗口删掉

E11QV(X8VTY6~HKE]3$]2Z4.png

    3.打开自动播放,设置为如图即可

B91`@L{ON11TR27L7]%EYUT.png

    4.在Tampermonkey中添加如下两个脚本即可

    第一个脚本Swu001

// ==UserScript==
// @name         Swu001
// @namespace    http://www.anyuer.club
// @version      1.0
// @description  Please use it with Swu002!
// @author       YuEr
// @match        *222.198.126.210/jjfz/lesson/video?lesson_id=*
// @match        *http://222-198-126-210.sangfor.vpn.swu.edu.cn:8118/jjfz/lesson/video?lesson_id=*
// @match        *222.198.126.210/jjfz/lesson/home*
// @match        *222-198-126-210.sangfor.vpn.swu.edu.cn:8118/jjfz/lesson/home*
// @match        *222.198.126.210/jjfz/lesson/lecture*
// @match        *222-198-126-210.sangfor.vpn.swu.edu.cn:8118/jjfz/lesson/lecture*
// @match        *222.198.126.210/jjfz/lesson/video*page=*
// @match        *222-198-126-210.sangfor.vpn.swu.edu.cn:8118/jjfz/lesson/video*page=*
// @icon         http://www.anyuer.club/zb_users/avatar/0.png
// @grant        none
// ==/UserScript==


function nextpage()
{
	var i = 0;
	var length = document.getElementsByClassName("pages")[0].childElementCount;
	while( i < length)
	{
		var text = document.getElementsByClassName("pages")[0].children[i].innerText
		//console.log(document.getElementsByClassName("pages")[0].children[i].innerText);
		if(text == "下一页")
		{
			console.log(i);
			return i;
			break;
		}
		else
		{
			console.log("none");
		}
		i = i +1;
	}
}
function overcheck()
{
	var returnnextpage = nextpage();
	if(undefined == returnnextpage)
	{
		//console.log("无下一页");
		alert("本节课刷完啦!");
	}
	else
	{
		//console.log("有呢");
		document.getElementsByClassName("pages")[0].children[returnnextpage].click();
	}
}



function confirmnewif()
{
	if(undefined == document.getElementsByClassName("lesson_index3_title")[0])
	{
		//console.log("OIDbanben");
		findclass();
	}
	else
	{
		//console.log("Newbanben");
		document.getElementsByClassName("lesson_index3_title")[0].click();
	}
}



//找到精品课程
function findclass()
{
	var text = document.getElementsByClassName("left_list_h2 left_list_h2_cut1")[0].innerText;
	if(text == "精品课程")
	{
		var ifname = document.getElementsByClassName("lesson1_right")[0].children[1].className;
		if(ifname == "lesson1_a_cut")
		{
			//throw new Error;
		}
		else
		{
			document.getElementsByClassName("lesson1_right")[0].children[1].click();
			throw new Error;
		}


	}
	else
	{
		document.getElementsByClassName("iconfont3")[1].click()
	}
}
//找到哪个链接是我要点的
function findurl()
{
	//开始是15,结束length-5
	var i = 15;
	var length = document.getElementsByTagName("li").length;
	while( i < length-5)
	{
		var nowtime = document.getElementsByTagName("li")[i].firstElementChild.lastElementChild.innerText;
		if(nowtime == "完成")
		{
			console.log("完成");
		}
		else
		{
			var mustif = document.getElementsByTagName("li")[i].children[1].children[3].firstElementChild.innerText;
			if(mustif == "选 修 ")
			{
				console.log("虽然没有学,但是该课程选修");
				//return 0;
			}
			else if(mustif == "必 修 ")
			{
				return i;
				break;
			}
		}
		i = i +1;
	}
}
function pen(num)
{
	document.getElementsByTagName("li")[num].firstElementChild.lastElementChild.click();
}


confirmnewif();
var num = findurl();
if(undefined == num )
{
	overcheck();
}
else
{
	setTimeout(pen(num), 1500);
	console.log(num);
}

    第二个脚本Swu002

// ==UserScript==
// @name         Swu002
// @namespace    http://www.anyuer.club/
// @version      1.0
// @description  Please use it with Swu001!
// @author       YuEr
// @match        *http://222.198.126.210/jjfz/pla*
// @match        *222-198-126-210.sangfor.vpn.swu.edu.cn:8118/jjfz/pla*
// @match        *222.198.126.210/fzdx/lesson/video*
// @match        *222.198.126.210/fzdx/play*
// @icon         http://www.anyuer.club/zb_users/avatar/0.png
// @grant        none
// ==/UserScript==



//安全检查,是否需要点击
function safetest(i)
{
	var name = document.getElementsByClassName("video_lists")[0].firstElementChild.children[i].className;
	if(name == "video_red1")
	{
	}
	else
	{
		document.getElementsByClassName("video_lists")[0].firstElementChild.children[i].firstElementChild.click();
	}
}
//寻找哪一节开始
function findstart()
{
	var length =  document.getElementsByClassName("video_lists")[0].firstElementChild.childElementCount;
	var i = 0;
	while(i < length)
	{
		var color = document.getElementsByClassName("video_lists")[0].firstElementChild.children[i].firstElementChild.style.color;
		if(color == "red")
		{
		}
		else
		{
			var name = document.getElementsByClassName("video_lists")[0].firstElementChild.children[i].className;
			safetest(i);
			break;
		}
		i = i +1;
	}
}


//点击确定
function ok()
{
	var ret = document.getElementsByClassName("public_submit")[0];
	if(undefined == ret )
	{
		//console.log("未找到确定按钮")
	}
	else
	{
		ret.click();
	}

}

//点击开始播放
function startbf()
{
	var p = document.getElementsByClassName("plyr__control plyr__control--overlaid")[0];
	var pp = p.className;
	if(pp == "plyr__control plyr__control--overlaid")
	{
		p.click();
	}
	else
	{
		//console.log("不用点开始咯");
	}

}

//播放下一条视频
function nextone()
{
	var listli = document.getElementsByTagName("li");
	var listlilength = listli.length;
	var i = 0;
	while( i < listlilength)
	{
		if(listli[i].className == "video_red1")
		{
			//console.log("找到了所在li的序列号");
			//console.log(i);
			rm = i +1 ;
			//var nextoneview = listli[rm].firstElementChild;
			if(i == listlilength - 1)
			{
				//console.log("本次js运行结束");
				document.getElementsByClassName("video_goback")[0].click();
			}
			else
			{
				listli[rm].firstElementChild.click();
			}
			//listli[rm].firstElementChild.click();
		}
		//console.log(listli[i]);
		i = i + 1 ;
	}
}

//主函数啦

findstart();

setInterval(() => {
	startbf();
	var publicnote = document.getElementsByClassName("public_text")[0];
	if(undefined == publicnote)
	{
	}
	else
	{
		var publicnoteview = publicnote.innerText;
		var publicnoteview = publicnote.textContent;
		if(publicnoteview == "当前视频播放完毕!")
		{
			nextone();
		}
		else if(publicnoteview.indexOf("上次观看到") != -1)
		{
			document.getElementsByClassName("public_cancel")[0].click();
		}
		else
		{
			ok();
		}
		//console.log(publicnoteview);
	}
},1000)

第三个脚本Swu003

// ==UserScript==
// @name         Swu003
// @namespace    http://www.anyuer.club/
// @version      1.0
// @description  Please use it with Swu002 and Swu003 请记得和Swu002 和Swu001 一起使用
// @author       YuEr
// @match        *222.198.126.210/fzdx/*
// @match        *222-198-126-210.sangfor.vpn.swu.edu.cn:8118/fzdx/*
// @match        *222.198.126.210/fzdx/lesson*
// @icon         http://www.anyuer.club/zb_users/avatar/0.png
// @grant        none
// ==/UserScript==


function overcheck()
{
    var allclassnum = document.getElementsByClassName("lesson1_img").length;
    var overclassnum = document.getElementsByClassName("lesson_pass").length;
    if(allclassnum == overclassnum)
    {
        alert("本节课刷完啦!");
    }
    else
    {
        setTimeout(3500);
        document.getElementsByClassName("lesson1_img")[overclassnum].click()
    }
}



function confirmnewif()
{
	if(undefined == document.getElementsByClassName("lesson_index3_title")[0])
	{
		//console.log("OIDbanben");
		findclass();
	}
	else
	{
		//console.log("Newbanben");
		document.getElementsByClassName("lesson_index3_title")[0].click();
	}
}



//找到精品课程
function findclass()
{
	var text = document.getElementsByClassName("left_list_h2 left_list_h2_cut1")[0].innerText;
	if(text == "精品课程")
	{
		var ifname = document.getElementsByClassName("lesson1_right")[0].children[1].className;
		if(ifname == "lesson1_a_cut")
		{
			//throw new Error;
		}
		else
		{
			document.getElementsByClassName("lesson1_right")[0].children[1].click();
			throw new Error;
		}


	}
	else
	{
		document.getElementsByClassName("iconfont3")[1].click()
	}
}



confirmnewif();
overcheck();

使用方法:

登录到党旗飘飘的网页,找到党课,点击开始学习,自动刷完该节课的所有必须视频内容

image.png


总结:

然后就可以睡觉,吃饭,写作业了,党课什么的,交给时间吧!

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论