Greasy Fork

来自缓存

Greasy Fork is available in English.

防掉线刷新助手

定期ajax刷新你的网页,防止你被session过期掉线。如果你登录的系统session过期很快,那么这将是神器。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         防掉线刷新助手
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  定期ajax刷新你的网页,防止你被session过期掉线。如果你登录的系统session过期很快,那么这将是神器。
// @author       lnwazg
// @match        *://*/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    var url = location.href;
    console.log("[LoginOnlinePlugin "+curentTime()+"] "+url+" 防掉线外挂已启用!");
    
    function get(url){
        console.log("[LoginOnlinePlugin "+curentTime()+"] request url="+url);
        var xmlHttpReq = null;
        if (window.ActiveXObject){
            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }else if (window.XMLHttpRequest){
            xmlHttpReq = new XMLHttpRequest();
        }
        xmlHttpReq.open("GET", url, true);
        xmlHttpReq.onreadystatechange = function(){
            if (xmlHttpReq.readyState == 4)
            {
                if (xmlHttpReq.status == 200)
                {
                    var result = xmlHttpReq.responseText;
                    console.log("[LoginOnlinePlugin "+curentTime()+"] 刷新成功!")
                }
            }
        };
        xmlHttpReq.send(null);
    }
    //对global的污染会造成奇怪的问题,因此千万不要随意为global的prototype增删方法
    //作为辅助插件,更要有这样的职业操守。
    function curentTime()
    {
        return new Date().toLocaleString();
    }
    var interval = 1000 * 120; //刷新间隔
    var req = function(){get(url);}
    setInterval(req, interval);
})();