Auto Task Framework

自动任务

Versione datata 29/11/2023. Vedi la nuova versione l'ultima versione.

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/462822/1287584/Auto%20Task%20Framework.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Auto Task Framework
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABmJLR0QA/wD/AP+gvaeTAAAFyklEQVR4nO2dS2hdRRiAv5vbSsREDK3FlagYDTSlYkVw0aK4lqpJtLZa0zR0W+1KLVhBqETQrQsfTVoffQgqdFuU6kYRpTVKHyiC0GLaxIpdVNPcuJh7Md6c3jv/nHmdnPng36Snc/4z353HmfOqUD5WAeuBfqAPuAvoAW4CuurbXAYuAX8Ap4FTwI/AceCC53yXJOuAN4AfgBowbxg14GS9rHu9HsESoBvYBUxiLqBdTALP81/LSmTQA+wBpnEnojkuAi+jur1EnQqwFfgdfyKaYxrYUc+l1NyOGnBDiWiOL4DbnB5xxGwEZggvoTn+BIYcHnd0VIAxwld8q6gBeylBF1YF3iF8hevGfmC5k5qIgOXAZ4Sv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YN6aAl4hwoXAL8clwOQ6dQF1civJ6hlTGONky9gnKaBezqIH1TtRLYb4m3/R7DnV3yBiOroHb6us2o14YVtXcfgJ13by24G8dqCnvsKWcrgJPAR83/b0LeAC4H3XPbS9wC+pVUI1feuNzFTMs/lzFtKX8nPEEsl/dRywW14FqMbZaRkNG6UgyIiLJiAgTGc0La0mGJYaQyThIkuEMGzKqJBlWsCVjQlBGqyg1sckotRDpQuEBFs+mqqgTR1syZl0caBEYRCbjEO5bRmnHjCQjImzJsNlNJRmakWQ4JMmIiEFkb+JxLaPUDBCXjFILkXZTWau2VeADQRntorTnGWBHxoeCMnRkRHU/k290K+ow2d2UyfeXrhWlHcAXkmRERpIRGa0q6ghJhneSjMiQyJC8oSDJMMSXjIQmvlpGQpOFMpofu7LZTSU0aSXD5nJIQpOsbmoZ5t8Lz4pSr01JyZIh+f6ejoxSr03lwXY3laa2OUgyIiMtoUeG9KphahkeyCslyXCAqZQkwwL/Ag+tV8ginTZwAAAAAElFTkSuQmCC
// @namespace    https://github.com/giveme0101/
// @version      3.2
// @description  自动任务
// @author       Kevin [email protected]
// @match        *://*/*
// @run-at       document-idles
// @noframes
// ==/UserScript==

/** auto task framework **/
const autoTask = {

    taskExec: function(_config) {

        const urlHost = window.location.host;
        const cfgHosts = _config.host, cfgTest = _config.test;

        let hostMatch = cfgHosts instanceof Array ? cfgHosts.some(ele => urlHost.contains(ele)) : urlHost.contains(cfgHosts);
        if (!hostMatch) return;

        let testMatch = (typeof test) === 'boolean' ? cfgTest : cfgTest();
        if (!testMatch) return;

        this.clog("Auto Task™", "3.2", "plugin active [" + _config.name + "]: " + _config.desc);
        _config.action(_config.param);
    },


    run: function(configs){
        for (const idx in configs){
            try {
                this.taskExec(configs[idx]);
            } catch(e){
                console.error("Auto Task™ plugin [" + configs[idx].name + "] throw exception: " + e);
            }
        }
    },

    clog: function(leftText, rightText, endText) {
        let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
        const opt = Object.assign({
            type: 'log',
            leftBGColor: '#555555',
            leftColor: '#ededed',
            rightBGColor: '#ffc107',
            rightColor: '#262318'
        }, options);
        console[opt.type]('%c' + leftText + '%c' + rightText + (endText ? '%c\n' + endText : ''), 'color: ' + opt.leftColor + ';background-color: ' + opt.leftBGColor + ';border-radius: 2px 0 0 2px;padding: 0 5px', 'color: ' + opt.rightColor + ';background-color: ' + opt.rightBGColor + ';border-radius: 0 2px 2px 0;padding: 0 5px;', '');
    },

    eleHide: function(ele, callback){
       var t = setInterval(function(){
           try {
               (typeof ele === "string" ? document.querySelector(ele) : ele).remove();
               clearInterval(t), t = null, callback && callback();
           } catch(e){}
       }, 100);
    }
}

window.autoTask = autoTask;