甜学院自动点击继续学习按钮

判断弹窗并点击继续学习按钮,同时检测并点击开始学习按钮

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         甜学院自动点击继续学习按钮
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  判断弹窗并点击继续学习按钮,同时检测并点击开始学习按钮
// @author       You
// @match        https://px.tianlala.com/o2o/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 点击弹窗中的“继续学习”按钮
    function clickContinueLearning() {
        // 查找所有 button 元素,并过滤出包含 "继续学习" 或 "开始学习" 的按钮
        var buttons = Array.from(document.querySelectorAll('button')).filter(function(button) {
            return /刷新|继续学习|开始学习/.test(button.textContent.trim());
        });

        // 如果找到符合条件的按钮,则点击第一个
        if (buttons.length > 0) {
            buttons[0].click();
            console.log('已点击包含“继续学习”或“开始学习”的按钮');
        } else {
            console.error('没有找到包含“继续学习”或“开始学习”的按钮');
        }

        var video = document.querySelector('video');
        if(video){
             video.play();
            video.playbackRate = 2
        }



        const playerArea = document.querySelector('.yxtulcdsdk-course-player__playeare');

        if (!playerArea) {
            console.warn('未找到课程播放区域 (.yxtulcdsdk-course-player__playeare)');
            return;
        }

        // 查找倒计时元素
        const countdownEl = playerArea.querySelector('.yxt-color-warning');

        if (!countdownEl || !countdownEl.textContent.trim()) {
            console.log('学习已完成或无倒计时信息');
            clickNextButton();
            return;
        }

        // 提取倒计时文本,例如:"7分钟 21秒"
        const text = countdownEl.textContent.trim();
        console.log(text);


        }


        function clickNextButton() {

            // 查找所有 button 元素,并过滤出包含 "下一个" 的按钮
            var buttons = Array.from(document.querySelectorAll('button')).filter(function(button) {
                return /下一个/.test(button.textContent.trim());
            });
            // 如果找到符合条件的按钮,则点击第一个
            if (buttons.length > 0) {
                buttons[0].click();
                console.log('已点击包含“下一个”的按钮');
            } else {
                console.error('没有找到包含“下一个”的按钮');
            }
        }

    // 每隔5秒检查一次
    setInterval(() => {
        clickContinueLearning();
    }, 3000);
})();