🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

U校园增加时长(修复必修弹窗)

生命短暂而美好,没时间纠结,没时间计较

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         U校园增加时长(修复必修弹窗)
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  生命短暂而美好,没时间纠结,没时间计较
// @author       handsometaoa
// @match        https://ucontent.unipus.cn/_pc_default/pc.html?cid=*
// @grant        none
// @license      GPL-3.0
// @compatible   chrome
// ==/UserScript==

//表示每个页面停留[minMinute分minSeconds秒,maxMinute分钟maxSeconds秒],可以自己设置
var minMinute=4;//最小分钟
var minSeconds=30;//最小秒数
var maxMinute=5;//最大分钟
var maxSeconds=30;//最大秒数

//计算实际停留时间,防止每个页面停留时间相同
function realTime() {
    let rate = Math.random();
    return (minMinute * 60 +minSeconds+((maxMinute-minMinute)*60+maxSeconds-minSeconds)* rate) * 1000;
}
//自动点击必修弹窗和麦克风弹窗 3000表示延迟3秒,因为弹窗有延迟,主要看反应速度。
setTimeout(() => {
    //关闭必修提示弹窗
    var x = document.getElementsByClassName("dialog-header-pc--close-yD7oN"); x[0].click();
    document.querySelector("div.dialog-header-pc--dialog-header-2qsXD").parentElement.querySelector('button').click();
}, 3000);

//跳转下一节
function switch_next(selector, classFlag) {
    let flag = false;
    for (let [index, unit] of document.querySelectorAll(selector).entries()) {
        if (flag) {
            unit.click();
            //防止必修弹窗失效,跳转便刷新页面,1000表示跳转1秒后刷新页面
            setTimeout(() => {
                location.reload();
            }, 1000);
            flag = false;
            break;
        }
        if (unit.classList.contains(classFlag)) {
            flag = true;
        }
    }
}
setTimeout(() => {
    switch_next('.layoutHeaderStyle--circleTabsBox-jQdMo a', 'selected');
    switch_next('#header .TabsBox li', 'active');
    switch_next('#sidemenu li.group', 'active');
}, realTime());