stayLoggedIn

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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...
})();