stayLoggedIn

Keeps you logged in on specific sites. (edit @match and @include to set your own sites)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         stayLoggedIn
// @author       Than
// @version      0.02
// @description  Keeps you logged in on specific sites. (edit @match and @include to set your own sites)
// @match        https://*.lithium.hosting:*/*
// @match        https://lithiumhosting.com/*
// @include      https://*.lithium.hosting:*/*
// @include      https://lithiumhosting.com/*
// @connect      lithiumhosting.com
// @grant        GM.xmlHttpRequest
// @grant        unsafeWindow
// @grant        GM_addStyle
// @grant        GM_setClipboard
// @run-at       document-end
// @namespace https://greasyfork.org/users/288098
// ==/UserScript==


(function() {
    'use strict';
    var gmFetch = function ({url, // Supply the URL you want to XHR
                             method="GET", // default method
                             data="", // post data, if needed
                             headers="", // includ headers as json.
                             anonymous=false, // true: no cookies will be included. false: default browser cookies will be included.
                             simple=true, // true returns just the response body. false returns the full response object.
                             onprogressCallback=false, // supply a function name for a callback
                             responseType = "text",
                            }) {
        return new Promise((resolve, reject) => {
            headers = ((method === "POST" && headers === "") ? {"Content-Type": "application/x-www-form-urlencoded"} : headers);
            //  console.log(GM.xmlHttpRequest);
            GM.xmlHttpRequest({
                method: method,
                url: url,
                headers: headers,
                data: data,
                anonymous: anonymous,
                onload: (simple ? e => resolve(e.response) : e => resolve(e)),
                onprogress: (onprogressCallback ? function (response) { onprogressCallback(response) } : false),
                onerror: reject,
                ontimeout: reject,
                responseType:responseType,
            });
        });
    }
    sendPing(document.location.href);
    /*--------------------------------------------------------------------------------------------------------------------
    ------------------------------------------- General functions --------------------------------------------------
    --------------------------------------------------------------------------------------------------------------------*/
    async function sendPing(url){
        console.log("ping active...")
        setInterval(sendRequest, 400000);
        async function sendRequest(){
            var response = await gmFetch({url:url});
            console.log(response);
            document.body.click();
            (function(path){
                var item = document.querySelector(path);
                if (!item){
                    document.body.appendChild(document.createTextNode('Error: '+path+' not found'));
                    return;
                };
                item.click();
                item.dispatchEvent(new Event('resize', {bubbles: true}));
            })('body');
        }
    } // Also, run all of the above when the document loads initially, not just during mutations
    // Your code here...
})();