Greasy Fork is available in English.

hclonely_auto_task

auto_task专用

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://greasyfork.org/scripts/379787-hclonely-auto-task/code/hclonely_auto_task.js?version=678120

    /*
    *empty():php empty()函数
    *isset():php isset()函数
    *getUrlQuery(e):获取url参数,e为URL链接,留空则为当前网址
    *unique(arr):数组去重,arr为要去重的数组
    *getCookie(name):读取cookies,name为cookie name,留空则返回所有cookie
    *toJSON(str):字符串转json
    *HCL.id(e,d):通过id获取元素,e为元素id,d为获取源
    *HCL.tag(e,d):通过id获取元素,e为元素tag,d为获取源
    *HCL.class(e,d):通过id获取元素,e为元素class,d为获取源
    *HCL.creat(e):创建元素,e为元素tag
    *HCL.ele(a):多项操作元素,a为字符串时创建元素,a为对象是多项操作
    *HCL.copy(a):复制
    *HCL.css.gm(e):添加全局css样式
    *HCL.css.js(e):添加全局css样式
    *HCL.log(e):控制台输出
    *HCL.c.l(e,c):控制台输出,c为颜色,默认蓝色
    *HCL.c.l2(e1,e2,c1,c2):控制台输出,c1为e1颜色,默认红色,c2为e3颜色,默认蓝色
    *HCL.c.gm(e):控制台输出
    *HCL.random(a,b):a-b随机数生成,b默认为0
    *HCL.randomColor():随机颜色生成
    *HCL.showTest():检测是否允许桌面通知
    *HCL.show(data):桌面通知,data={title:通知标题,msg:通知内容,icon:图标,time:关闭时间,onclick:点击事件,onerror:错误事件,onshow:显示事件,onclose:关闭事件}
    */

    //php empty()函数
    function empty(e,q=0){
        switch(e){
            case false:
            case null:
            case undefined:
            case "":
            case "0":
            case 0:
            case 0.0:
                return true;
                break;
            default:
                if((Array.isArray(e)||q==1)&&(e.length===0)){
                    return true;
                }else if(Object.prototype.toString.call(e)==="[object Object]"&&(Object.keys(e).length===0)){
                    return true;
                }else{
                    return false;
                }
                break;
        }
    }
    //php isset()函数
    function isset(e){
        switch(e){
            case false:
            case null:
            case undefined:
                return false;
                break;
            default:
                return true
                break;
        }
    }
    //获取url参数
    function getUrlQuery(e){
        let url=e||location.search;
        let strObj={};
        if (url.indexOf("?") != -1) {
            let str = url.substr(url.indexOf("?")+1);
            str.split("&").map(function(e){
                let a=e.split("=");
                strObj[a[0]]=decodeURIComponent(a[1]);
            });
        }
        return strObj;
    }
    //数组去重
    function unique(arr){
        return [...new Set(arr)];
    }
    //读取cookie
    function getCookie(name=""){
        let cookies=document.cookie;
        let cookieArray=cookies.split(/; ?/);
        let cookie={};
        for (let i=0;i<cookieArray.length;i++){
            let ck=cookieArray[i].split("=");
            cookie[ck[0]]=ck[1];
        }
        if(name==""){
            return cookie;
        }else{
            return cookie[name];
        }
    }
    var HCL={
        id:function(e,d=document){return d.getElementById(e)},//通过id获取元素
        tag:function(e,d=document){return d.getElementsByTagName(e)},//通过tag获取元素
        class:function(e,d=document){return d.getElementsByClassName(e)},//通过class获取元素
        creat:function(e){return document.createElement(e)},//创建元素
        ele:function(a){
            let e="";
            if(typeof(a) == 'string'){
                e=document.createElement(a);
            }else{
                e=typeof(a.ele) == 'string'?document.createElement(a.ele):a.ele;
                for(let i in a) {
                    if(i!="ele"){
                        if(i=="parent"){
                            a[i].appendChild(e);
                        }else if(i=="html"){
                            e.innerHTML=a[i];
                        }else if(i=="text"){
                            e.innerText=a[i];
                        }else if(i=="onclick"){
                            e.onclick=a[i];
                        }else{
                            e.setAttribute(i, a[i]);
                        }
                    }
                }
            }
            return e;
        },
        copy:function(e){GM_setClipboard(e)},//复制
        css:{//style样式
            gm:function(e){GM_addStyle(e)},
            js:function(e){
                let style=document.createElement("style");
                style.innerHTML=e;
                document.getElementsByTagName("head")[0].appendChild(style);
            }
        },
        log:function(e){console.log(e)},
        c:{//控制台输出
            l:function(e,c="blue"){console.log("%c"+e,"color:"+c)},
            l2:function(e1,e2,c1="red",c2="blue"){console.log("%c"+e1+"%c"+e2,"color:"+c1,"color:"+c2)},
            gm:function(e){GM_log(e)}
        },
        random:function(a,b=0){//随机数生成
            if(a){
                let max=Math.max(a,b);
                let min=Math.min(a,b);
                return min+Math.floor(Math.random()*(max-min+1));
            }else{
                return Math.random();
            }
        },
        randomColor:function(){//随机颜色生成
            let s16=Math.floor(Math.random()*(16777216)).toString(16);
            let s="000000"+s16;
            return "#"+s.substr(s.length-6,6);
        },
        show:function (data) {
            let options = {
                body: data.msg,
                icon: data.icon||"https://www.hclonely.cn/favicon.ico"
            };
            let Notification = window.Notification || window.mozNotification || window.webkitNotification;
            if (Notification && Notification.permission === "granted") {
                let instance = new Notification(data.title, options);
                instance.onclick = function() {
                    data.onclick();
                };
                instance.onerror = function() {
                    data.onerror();
                };
                instance.onshow = function() {
                    data.onshow();
                    if(data.time!=0){
                        setTimeout(function () {
                            instance.close();
                        },data.time)
                    }
                };
                instance.onclose = function() {
                    data.onclose();
                };
            } else if (Notification && Notification.permission !== "denied") {
                Notification.requestPermission(function(status) {
                    if (Notification.permission !== status) {
                        Notification.permission = status;
                    }
                });
            } else {
                return false;
            }
        },
        showTest:function () {
            let Notification = window.Notification || window.mozNotification || window.webkitNotification;
            if (Notification && Notification.permission === "granted") {
            } else if (Notification && Notification.permission !== "denied") {
                Notification.requestPermission(function(status) {
                    if (Notification.permission !== status) {
                        Notification.permission = status;
                    }
                });
            } else {
                return false;
            }
        }
    };