Greasy Fork

来自缓存

Greasy Fork is available in English.

学堂在线刷课脚本

学堂在线刷课脚本,自动静音和二倍速,只有刷课的功能。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         学堂在线刷课脚本
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  学堂在线刷课脚本,自动静音和二倍速,只有刷课的功能。
// @author       Saafo
// @license      LGPL-3.0-only
// @match        https://next.xuetangx.com/learn/*
// @grant        none
// ==/UserScript==



function sleep (time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}
(async function() {
    'use strict';
    await sleep(1000);
    var courses = document.getElementsByClassName("noScore");
    var currentCourse = "";
    var j = 0;
    for(j = 0;j< courses.length;j++){
        if(courses[j].parentElement.getAttribute("class") == "title active"){
            currentCourse = courses[j];
            break;
        }
    }
    await sleep(2000);
    var isVideo = false;

    for(let i = 0;i< 50000;i++){
        if(document.getElementsByClassName("xt_video_player_common_icon").length != 0){
            document.getElementsByClassName("xt_video_player_common_icon")[0].click();//静音
            document.getElementsByClassName("xt_video_player_common_list")[0].children[0].click();//二倍速
            isVideo = true;
            break;
        }
    }
    if(!isVideo){
        courses[j+1].click();//跳到下一个视频
        await sleep(500);
        window.location.reload();
    }

    if(currentCourse != ""){
        //开始等待
        var timeBlock = document.getElementsByClassName("xt_video_player_current_time_display")[0].textContent;
        var currentTimeRaw = timeBlock.split(' / ')[0];
        var timeLengthRaw = timeBlock.split(' / ')[1];
        var currentTime = (+currentTimeRaw.split(':')[0])*3600 + (+currentTimeRaw.split(':')[1])*60 + (+currentTimeRaw.split(':')[2]);
        var timeLength = (+timeLengthRaw.split(':')[0])*3600 + (+timeLengthRaw.split(':')[1])*60 + (+timeLengthRaw.split(':')[2]);
        await sleep((timeLength - currentTime)*500);
        courses[j+1].click();//跳到下一个视频
        console.log('开始刷课');
        await sleep(500);
        window.location.reload();
    }else{
        alert("出错,脚本已经停止运行。")
    }
    // Your code here...
})();