Auto Press Down Key for Changjiang Yuketang

每隔15秒模拟按下向下键,仅在长江雨课堂下执行

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @license MIT
// @name         Auto Press Down Key for Changjiang Yuketang
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  每隔15秒模拟按下向下键,仅在长江雨课堂下执行
// @author       Your Name
// @match        https://changjiang.yuketang.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定义按键函数
    function pressDownKey() {
        // 创建按下向下键的事件
        const event = new KeyboardEvent('keydown', {
            key: 'ArrowDown',
            keyCode: 40,
            code: 'ArrowDown',
            which: 40,
            bubbles: true
        });
        // 触发事件
        document.dispatchEvent(event);
    }

    // 定义一个函数来设置下一个随机间隔时间
    function scheduleNextPress() {
        const minInterval = 15000; // 最小间隔时间15秒
        const maxInterval = 20000; // 最大间隔时间20秒
        const randomInterval = Math.floor(Math.random() * (maxInterval - minInterval + 1)) + minInterval;
        
        setTimeout(() => {
            pressDownKey();
            scheduleNextPress();
        }, randomInterval);
    }

    // 开始第一次调度
    scheduleNextPress();
})();