Greasy Fork

Greasy Fork is available in English.

福大长江雨课堂自用

福大长江雨课堂自用,无答题

当前为 2021-11-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         福大长江雨课堂自用
// @namespace    http://tmpermonkey.net/
// @version      0.3
// @description  福大长江雨课堂自用,无答题
// @author       alep
// @match        *://*.yuketang.cn/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @run-at       document-end
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function goNextVideo(){
        var url = window.location.href;
        var newVideoId = parseInt(/video\/([0-9]+)$/.exec(url)[1]) + 1;
        var newUrl = url.replace(/video\/[0-9]+$/,"video/" + newVideoId);
        window.location.href = newUrl;
    }


    function main(){
        var progress = 'null';
        try{
            var video_elem = document.querySelector("video");
            if(video_elem != null){
                video_elem.muted = true;
                video_elem.play();
                video_elem.playbackRate = 2.0;
                document.querySelector(".xt_video_player_speed").click();
                var speed = document.querySelector(".xt_video_player_common_list");
                var speedChild = speed.firstChild;
                speedChild.click();
            }
        }catch(e){
            console.log(e);
        }

        try{
            progress = document.querySelectorAll('span.text')[1].textContent.split(":")[1];
        }catch(e){
            console.log('读取时出错,查看是否为video');
            var elem= document.querySelector('span.text');
            if(!elem.textContent.match('Video')){
                goNextVideo();
                return;
            }
        }
        try{

            document.querySelector('div.title-fl:first-child').innerText = '脚本检测到进度:' + progress;
            if(progress == '100%'){
                goNextVideo();
                return;
            }
            setTimeout(main, 1000);
        }catch(e){
           console.log('读取时出错,尝试重试');
           location.reload();
           setTimeout(main, 5000);
        }

    }

    var url = window.location.href;
    if (url.match("/video")){
        if (window.onurlchange === null) {
            window.addEventListener("urlchange", () => {
                setTimeout(main, 2000);
            });
        }
        setTimeout(main, 2000);
    }
    // Your code here...
})();