Auto Task Framework

自动任务

Version vom 28.11.2023. Aktuellste Version

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/462822/1287166/Auto%20Task%20Framework.js

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Auto Task Framework
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABmJLR0QA/wD/AP+gvaeTAAAFyklEQVR4nO2dS2hdRRiAv5vbSsREDK3FlagYDTSlYkVw0aK4lqpJtLZa0zR0W+1KLVhBqETQrQsfTVoffQgqdFuU6kYRpTVKHyiC0GLaxIpdVNPcuJh7Md6c3jv/nHmdnPng36Snc/4z353HmfOqUD5WAeuBfqAPuAvoAW4CuurbXAYuAX8Ap4FTwI/AceCC53yXJOuAN4AfgBowbxg14GS9rHu9HsESoBvYBUxiLqBdTALP81/LSmTQA+wBpnEnojkuAi+jur1EnQqwFfgdfyKaYxrYUc+l1NyOGnBDiWiOL4DbnB5xxGwEZggvoTn+BIYcHnd0VIAxwld8q6gBeylBF1YF3iF8hevGfmC5k5qIgOXAZ4SvZGl8Cixrd3BFa0oVYBw1m8rDX8CXqInAJHAWdQZ+uf7vXcDNQC+wBn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/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) {
 
        let hostMatch = false, hosts = _config.host;
        if (hosts instanceof Array) {
            const urlHost = window.location.host;
            for (const idx in hosts) {
                if (hosts[idx] == urlHost) {
                    hostMatch = true;
                    break;
                }
            }
        } else {
            hostMatch = _config.host == window.location.host;
        }
 
        if (!hostMatch) {
            return;
        }
 
        let testMatch = false, test = _config.test;
        if ((typeof test) === 'boolean') {
            testMatch = test;
        } else if (test instanceof Function) {
            testMatch = test();
        }
 
        if (!testMatch) {
            return;
        }
 
        this.clog("Auto Task™", "3.0", "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;