我爱学习

内部使用

// ==UserScript==
// @name         我爱学习
// @license MIT
// @namespace    http://tampermonkey.net/
// @version      0.3.0
// @description  内部使用
// @author       You
// @run-at       document-end
// @match        https://*.yunxuetang.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=yunxuetang.cn
// @grant        none
// ==/UserScript==

// 定义时间加速倍数
const timeScale = 10;
const originalSetTimeout = window.setTimeout;
const originalSetInterval = window.setInterval;
/*

// 重写 setTimeout 和 setInterval
(function () {
  window.setTimeout = function (callback, delay, ...args) {
    //console.log("speedup setTimeout", timeScale);
    return originalSetTimeout(callback, delay / timeScale, ...args);
  };

  window.setInterval = function (callback, delay, ...args) {
    console.log("speedup setInterval", timeScale);
    return originalSetInterval(callback, delay / timeScale, ...args);
  };
})();
*/


function refresh() {

    if(window.location.pathname.includes("scowrapperstudy.html")) {
        document.querySelector("iframe").focus();
    } else if(window.location.pathname.includes("video.html")) {
        if(document.querySelector("#video")) {
            document.querySelector("#video").focus();
        }


        var start = document.querySelector("xg-start.xgplayer-start");
        if(start) {
            start.click();
        }
    } else {
        emitClickAtCenter();
    }


    var conti = document.querySelector("div.yxtf-dialog__wrapper > div > div > div > div:nth-child(4) > button ");
    if(conti && conti.textContent == "继续学习") {
        conti.click();
    }



    var learn = document.querySelector("span.yxtulcdsdk-flex-center-center");
    if(learn) {
        console.log("start learn");
        learn.click();
    }

    var next = document.querySelector("button.yxtf-button.ml12.yxtf-button--default.is-plain.is-icon");
    if(!next) {
        next = document.querySelector("div.yxtulcdsdk-course-player__kng-operate.mt12 > div:last-child")
    }
    if(!next) {
        return;
    }

    var element = document.querySelector("div.task-content-active svg.yxt-svg-icon.mr8.mt2.ml14 > path");
    if(element && element.getAttribute("fill") == '#52C41A') {
        console.log("finish");
        next.click();
        return;
    }
    element = document.querySelector("li.liactive  svg path[stroke]");
    if(element && element.getAttribute("stroke")) {
        console.log("finish");
        next.click();
        return;
    }
/*
    var nextChapter = document.querySelector("button.ulcdsdk-nextchapterbutton");
    if(nextChapter) {
        console.log("start nextChapter");
        nextChapter.click();
        return;
    }
*/

    var progress = document.querySelector("span.yxt-color-warning");
    if(!progress) {
        console.log("no progress bar");
        var refresh = document.querySelector("span.yxtulcdsdk-flex-center");
        if(refresh && refresh.textContent == "刷新"){
            refresh.click();
        }
    } else {
        console.log("progress", progress.textContent);
    }



    //var next = document.querySelector("span > i.yxtf-icon-arrow-right");

    if(progress && progress.textContent == "0秒") {
        setTimeout(function(){next.click();}, 1000)
    }
    var msg = document.querySelector("div.yxtbiz-language-slot")
    if(msg && msg.textContent.includes("1加油")){
        console.log("progress", msg.textContent);
        next.click();
    }
}

function emitClickAtCenter() {
    // Calculate the center of the page
    const centerX = window.innerWidth / 2;
    const centerY = window.innerHeight / 2;

    // Create a new mouse event
    const clickEvent = new MouseEvent("click", {
        bubbles: true, // Allow event to bubble up the DOM
        cancelable: true, // Allow event to be cancelable
        clientX: centerX, // Set X-coordinate of the click
        clientY: centerY, // Set Y-coordinate of the click
        view: window, // The associated window object
    });

    // Dispatch the event on the document element
    document.elementFromPoint(centerX, centerY)?.dispatchEvent(clickEvent);
    document.elementFromPoint(centerX, centerY)?.dispatchEvent(clickEvent);
}

(function() {
   'use strict';
   originalSetInterval(refresh, 3000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址