我爱中国共产党!党旗飘飘,只是不希望被无意义而且频繁的弹窗打断我的课程学习(欸嘿)
当前为
// ==UserScript==
// @name 党旗飘飘~~~UESTC专用
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 我爱中国共产党!党旗飘飘,只是不希望被无意义而且频繁的弹窗打断我的课程学习(欸嘿)
// @author Onion
// @include https://dxpx.uestc.edu.cn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=uestc.edu.cn
// @grant none
// @license MIT
// ==/UserScript==
//1.0 demo版本,还没学会用cookies,因为不想默认开启,所以没办法在重新定向网页的时候,保留用户按下按钮事件的value,过几天修复这个问题(大饼
//本站只匹配了UESTC的党旗飘飘网站,有需要的可以自行修改includ为自家网站
//用法:点开始,就开刷
//停止,就不执行脚本
(function() {
'use strict';
function clickPlayBtn(){
var temp = document.createEvent("MouseEvents"); //建立鼠标事件
temp.initEvent("click", true, true);
var list = document.getElementsByClassName("plyr__controls__item plyr__control");//播放按钮
for (let i = 0; i < list.length; i++) {
const btn = list[i];
if(btn.getAttribute("aria-label") == "Play"){
btn.dispatchEvent(temp)
}
}
}//这几行没啥用
function random_Times(){
var times= Math.floor((Math.random()*3)+1) //随机
return times;
}
var button_1 = document.createElement("button"); //创建一个按钮
button_1.textContent = "开刷"; //按钮内容
button_1.style.width = "109px"; //按钮宽度
button_1.style.height = "32px"; //按钮高度
button_1.style.align = "center"; //居中
button_1.style.color = "black"; //按钮文字颜色
button_1.style.background = "pink"; //按钮底色
button_1.addEventListener("click", clickButton_1)
var button_2 = document.createElement("button"); //创建一个按钮
button_2.textContent = "不刷了"; //按钮内容
button_2.style.width = "109px"; //按钮宽度
button_2.style.height = "32px"; //按钮高度
button_2.style.align = "center"; //居中
button_2.style.color = "black"; //按钮文字颜色
button_2.style.background = "pink"; //按钮底色
button_2.addEventListener("click", clickbutton_2)//祖传按钮
var video = document.querySelector("video");
function clickButton_1(){
starting();
console.log("开刷")
}
function clickbutton_2(){
clearInterval(window.start);
console.log("不刷了不刷了,累了累了")
video.pause();
return;
}
var i=0; // 拦截次数
var toolbox = document.getElementsByClassName('video_tab')[0];
toolbox.appendChild(button_1);
toolbox.appendChild(button_2);
var para= document.createElement("p")
document.getElementsByClassName("video_cont")[0].appendChild(para);
//主函数:
function starting(){
window.start=setInterval(function(){ //循环开始
if (document.getElementsByClassName("video_red1")[0].children[0].style.color==="red" && document.getElementsByClassName("video_red1")[0].nextSibling.nextSibling!==null){
document.getElementsByClassName("video_red1")[0].nextSibling.nextSibling.children[0].click();
}
else{
if(document.getElementsByClassName("video_red1")[0].children[0].style.color==="red" && document.getElementsByClassName("video_red1")[0].nextSibling.nextSibling===null){
alert("臭宝这章学完啦!")
console.log("宝儿去下一章吧")
//window.clearInterval(start);
clearInterval(window.start);
}
else{ //开刷!!!
var video = document.querySelector("video");
if(video.paused){
video.play();
}
if(document.getElementsByClassName("public_cancel")[0]===undefined){
console.log("我刷")
}
else{
document.getElementsByClassName("public_cancel")[0].click();
i=i+1;
console.log("拦截成功")
// setTimeout(function(){
// console.log("inside_Fun")
// document.getElementsByClassName("plyr__control")[0].click(); 谷歌浏览器禁止了这个操作,但我还是找到其他方法了QAQ
// },4000);
}
if (document.getElementsByClassName("public_submit")[0]===undefined){
console.log("我刷")
}
else{
document.getElementsByClassName("public_submit")[0].click();
// document.getElementsByClassName("plyr__control")[0].click();
console.log("拦截成功")
i=i+1;
}
}
}
document.getElementsByClassName("video_cont")[0].children[2].innerText='欸嘿,我已经拦截了'+i+'次弹窗咯';
} ,2*1000)
}
})();