Greasy Fork

Greasy Fork is available in English.

教师研修网学习外挂

自动挂机学习。

当前为 2018-08-24 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         教师研修网学习外挂
// @namespace    http://greasyfork.icu/zh-CN/users/41249-tantiancai
// @version      0.6
// @description  自动挂机学习。
// @author       Tantiancai
// @match        http://i.yanxiu.com/uft/course/*
// @grant        none
// ==/UserScript==
(function () {
    'use strict';

    function getUnsafeWindow() {
        if(this)
        {
            console.log(this);
            if (typeof(this.unsafeWindow) !== "undefined") {//Greasemonkey, Scriptish, Tampermonkey, etc.
                return this.unsafeWindow;
            } else if (typeof(unsafeWindow) !== "undefined" && this === window && unsafeWindow === window) {//Google Chrome natively
                var node = document.createElement("div");
                node.setAttribute("onclick", "return window;");
                return node.onclick();
            }else
            {
            }
        } else {//Opera, IE7Pro, etc.
            return window;
        }
    }
    var myUnsafeWindow = getUnsafeWindow();
    var doc = myUnsafeWindow.document;
    var processTimer = null;
    var cntRetry = 0;
	myUnsafeWindow.clearInterval(processTimer);
    processTimer = myUnsafeWindow.setInterval(TimeProcess, 1000);

    function TimeProcess()
    {
        if($('.clock-tip').css('display') != 'none')
        {
	        console.log('%c Click th Tip', 'color:blue');
	        myUnsafeWindow.setTimeout(ClickTip, 5000);
        }

        if(parseFloat($('.slider-range')[0].style.width) >= parseFloat('100%'))
        {
	        console.log('%c Setting Next Page...', 'color:blue');
	        myUnsafeWindow.setTimeout(SetNextUrl, 10000);
	        myUnsafeWindow.clearInterval(processTimer);
        }
    }

    function ClickTip()
    {
	    $('.clock-tip').click();
    }

    function SetNextUrl()
    {
	    var thisUrl = myUnsafeWindow.location.href;
	    var nextUrl = '';
	    var index = 0;
	    var li = $($('.class_all').find('li')[0]);
		var thisA = li.find('a.doc_tit.video.click.video_focus');
		var nextA = thisA.next();
	    
	    if(nextA.length == 0)
	    {
		    var trainingid = GetParamValue(thisUrl, 'trainingid');
		    var courseid = GetParamValue(thisUrl, 'courseid');
		    nextUrl = '/uft/course/courseview.vm?trainingid=' + trainingid + '&courseid=' + (parseInt(courseid) + 1);
	    }
	    else
	    {
		    nextUrl = nextA.attr('href');
	    }

	    myUnsafeWindow.location.href = nextUrl;
    }

    function GetParamValue(url, key){
    	var regex = new RegExp(key + '=([^&]*)', 'i');
	    return url.match(regex)[1];
	}
})();