gcc vpn防掉线

每隔一分钟访问一次指定的URL

// ==UserScript==
// @name         gcc vpn防掉线
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  每隔一分钟访问一次指定的URL
// @author       LinXingJun
// @include      *://*.vpn.gcc.edu.cn:*/*
// @include      *://vpn.gcc.edu.cn/*
// @grant        GM_xmlhttpRequest
// @connect      *
// @license MIT
// ==/UserScript==
function gethtml(){
    var url = "http://"+window.location.hostname+":8118/"
    console.log("开始请求:"+Date.now()+url);
    GM_xmlhttpRequest({
            method: "GET",
            url: url,
            headers: {
                "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
            },
            onload: function(response){
                console.log("请求成功:"+Date.now());
            },
            onerror: function(response){
                console.log("请求失败:"+Date.now());
                console.log(response);
            }
        })
}
(function() {
    gethtml();
    // 定义每60秒(60000毫秒)执行一次函数
    setInterval(gethtml, 60000); // 60000ms = 1分钟
})();