eval这个里面到底是什么意思

dlksajfklj 发布于 2015/04/02 11:17
阅读 1K+
收藏 0
eval(function(p, a, c, k, e, r) {
    e = function(c) {
        return (c < 62 ? '': e(parseInt(c / 62))) + ((c = c % 62) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
    };
    if ('0'.replace(0, e) == 0) {
        while (c--) r[e(c)] = k[c];
        k = [function(e) {
            return r[e] || e
        }];
        e = function() {
            return '([6-9a-gj-lnoq-yA-Z]|[12]\\w)'
        };
        c = 1
    };
    while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
    return p
} ('(9($){7(I.1I){I.o=I.1I}7(I.o===\'k\'){v.c("浏览器不支持o...");C w}b 1d={f:\'d://127.0.0.1:9007\',l:w,1J:S,1e:30000,1K:1.5,1L:2000,X:1f,Y:w,1g:"",1M:0};$.u=9(T){7(!T){T={}}1h(b J in 1d){7(n T[J]!==\'k\'){a[J]=T[J]}g{a[J]=1d[J]}}a.1j=0;a.D=o.1N;a.d=1f;b 1k=w;b 1l=w;a.U=[];a.x=[];a.y=[];a.1m=9(Z){6.d=1O o(6.f,6.X||[]);7(!Z){6.c("connecting...")}6.c(\'u\',\'attempt-connect\',6.f);b 1P=6.d;b E=10(9(){6.c(\'u\',\'connection-E\',6.f);1P.11();1l=w},6.1L);6.d.1Q=9(j){1R(E);6.c(\'u\',\'1Q\',6.f);6.X=6.d.X;6.D=o.12;6.1j=0;Z=w;6.V();6.c(6.x);7(6.x.F>0){1h(b i=0;i<6.x.F;i++){7(n 6.x[i]!=="k"){6.x[i](j)}}}7(n 6["1S"]!=="k"){6["1S"](j)}};6.d.1n=9(j){1R(E);6.c(\'u\',\'1n\',6.f,j);6.V();6.d=1f;7(1k){6.D=o.CLOSED}g{6.D=o.1N;7(!Z&&!1l){6.c(\'u\',\'1n\',6.f)}b E=6.1J*Math.pow(6.1K,6.1j);10(9(){6.1m(1o)},E>6.1e?6.1e:E)}6.c(6.y);7(6.y.F>0){1h(b i=0;i<6.y.F;i++){7(n 6.y[i]!=="k"){6.y[i](j)}}}7(n 6["1T"]!=="k"){6["1T"](j)}};6.d.1U=9(j){6.c(\'u\',\'1U\',6.f,j);7(j.8){b 8=1V.parse(j.8);7(8.13==2){7("14"in 8){7(n 6.U[8.14]!=="k"){try{6.U[8.14](8)}catch(1W){6.c("U uncall",1W.message)}}g{7(n 6["K"]!=="k"){6["K"](8)}g{6.c("K 1p",8)}}}g{7(n 6["K"]!=="k"){6["K"](8)}g{6.c("K 1p",8)}}}g 7(8.13==1){7("q"in 8){b q="on"+6.1q(8.q);7(n 6[q]!=="k"){6[q](8)}g{6.c("q 1p",q,8)}}g{6.c("q 1Y set",8)}}}};6.d.1Z=9(j){6.c(\'u\',\'1Z\',6.f,j);7(n 6["20"]!=="k"){6["20"](j)}}};a.1r=9(m,L){m="on"+6.1q(m);6[m]=L};a.openHandle=9(L){b M=21(6.x.F);6.x[M+1]=L};a.closeHandle=9(L){b M=21(6.y.F);6.y[M+1]=L};a.c=9(){7(6.l){b 22=e.F;switch(22){N 5:v.l(e[0],e[1],e[2],e[3],e[4]);O;N 4:v.l(e[0],e[1],e[2],e[3]);O;N 3:v.l(e[0],e[1],e[2]);O;N 2:v.l(e[0],e[1]);O;N 1:v.l(e[0]);O;N 0:O}}};a.start=9(){6.23();7(6.Y){6.24()}6.1m(w)};a.15=9(q,1s,25,26){7(6.d&&6.D==o.12){b W=6.27();b 8={q:q,1s:1s,14:W,13:1,sign:""};6.U[W]=25;7(6.l){v.l(\'u\',\'15\',6.f,8)}C 6.d.15(1V.stringify(8))}g{7(6.l){v.l(\'u can 1Y 15 , websocket is unconnection\')}26()}};a.11=9(P,28){7(n P==\'k\'){P=S}1k=1o;7(6.d){6.d.11(P,28)}6.V()};a.refresh=9(){7(6.d){6.d.11()}6.V()};a.29=9(){C 1O Date().getTime()};a.27=9(){C 6.29()};a.1q=9(1t){C 1t.2a(0,1).toUpperCase()+1t.2a(1)};a.23=9(){7(6.l){v.l("添加状态浮层...")}b 2b=\'<Q W="A-2c"></Q>\';$(\'1u\').1v(2b);6.G=$(\'#A-2c\');6.G.B({\'1w\':\'2d\',\'z-M\':S,\'1x\':\'30px\',\'1y\':\'16px\',\'2e\':\'2f\',\'2g\':\'2h\',\'r-16\':\'2f 2h\',\'r-17\':\'no-17\',\'1z\':\'1A\'});6.c("添加提示浮层...");b 2j=\'<Q W="A-2k"></Q>\';$(\'1u\').1v(2j);6.H=$(\'#A-2k\');6.H.B({\'1w\':\'2d\',\'z-M\':S,\'1x\':\'91px\',\'1y\':\'41px\',\'2e\':\'2l\',\'2g\':\'2l\',\'r-1w\':\'1x 1y\',\'r-17\':\'no-17\',\'1z\':\'1A\'});6.c("绑定bar 1B事件...");6.G.1r(\'1B\',9(){7(6.H.B(\'1z\')==\'1A\'){6.H.R("fadeIn",{18:2m})}g{6.H.R("fadeOut",{18:2m})}7(6.D!=o.12&&6.1g){I.2n=6.1g}})};a.24=9(){6.G.2o();6.Y=1o};a.hiddenStatusBar=9(){6.G.hidden();6.Y=w};a.V=9(){7(6.D==o.12){6.G.B({\'r-19\':\'f("/1a/A/onlineIcon@2x.1b")\'});6.H.B({\'r-19\':\'f("/1a/A/onlineBubble@2x.1b")\',\'r-16\':\'2p 2q\'})}g{6.G.B({\'r-19\':\'f("/1a/A/offlineIcon@2x.1b")\'});6.H.B({\'r-19\':\'f("/1a/A/offlineBubble@2x.1b")\',\'r-16\':\'2p 2q\'})}};a.recivedPushTask=9(1C){6.1r("task_result",9(8){7(n 8.P!="k"&&8.P==0){b 1c=8.8.1c;b 1D="finished_task_"+6.1M+"_"+1c;7(!2r.getItem(1D)){2r.setItem(1D,1)}g{$.ajax({f:\'http://m.qianka.com/already/done\',8:{task_id:1c},13:\'get\',datatype:\'json\'});C}$(\'1u\').1v(\'<Q class="s-t"><p></p></Q>\');$(".s-t").find("p").html("您完成限时推荐《"+8.8.2s.subtitle+"》,获得 <2t>"+8.8.2s.subcurrency+"</2t> 金");b h=parseFloat($(".s-t").innerHeight());$(".s-t").B({"1E":-h+"px","visibility":"visible","r-16":"100%"});b 1F=1G;9 1H(){$(\'.s-t\').R("2u");$(\'.s-t\').R({\'1E\':-h},{18:1F});10(9(){$(\'.s-t\').R("2u");$(".s-t").remove();7(1C){I.2n.1C()}},S)}$(".s-t").2o();$(".s-t").1B(9(){1F=1G;1H()});$(\'.s-t\').R({\'1E\':0},{18:1G});10(1H,5000)}g{}})};b 6=a;C 6}})(jQuery);', [], 155, '||||||self|if|data|function|this|var|log|ws|arguments|url|else|||event|undefined|debug||typeof|WebSocket||action|background|gs|notification|GSWebsocket|console|false|openHandles|closeHandles||weixin|css|return|readyState|timeout|length|statusBarId|statusBubbleId|window|key|onMessage|fn|index|case|break|code|div|velocity|1000|options|callbacks|listenStatusBar|id|protocol|showBar|reconnectAttempt|setTimeout|close|OPEN|type|sid|send|size|repeat|duration|image|img|png|tid|settings|maxReconnectInterval|null|applink|for||reconnectAttempts|forcedClose|timedOut|open|onclose|true|unhandle|ucfirst|bind|params|str|body|append|position|bottom|right|display|none|click|reload|ls_key|top|closeTime|300|closeNotification|MozWebSocket|reconnectInterval|reconnectDecay|timeoutInterval|uid|CONNECTING|new|localWs|onopen|clearTimeout|onOpen|onClose|onmessage|JSON|err||not|onerror|onError|parseInt|count|initStatusBar|showStatusBar|success|faile|uuid|reason|timestamp|substring|strMonitor|monitor|fixed|width|47px|height|58px||strBubble|bubble|150px|200|location|show|100px|44px|localStorage|task_info|span|finish'.split('|'), 0, {}))


---------------------
看不懂这个具体里面的功能js是什么作用的。希望能代码导读。谢谢

这个好像是WebSocket  js代码不知道大家是否。

加载中
0
Mc___
Mc___

eval 是一个把字符串当作表达式执行而返回一个结果的函数,经常用在有字符串处理的时候。

0
滴滴丶哔哔
滴滴丶哔哔
这个嘛就是限时推荐的逻辑嘛
0
欣儿
欣儿
js加密过,去解开吧
0
飘逸的逸
飘逸的逸

http://www.w3school.com.cn/jsref/jsref_eval.asp

LZ看这里

0
m
magiclogy

大概是压缩?

(function ($) {
    if (window.MozWebSocket) {
        window.WebSocket = window.MozWebSocket
    }
    if (window.WebSocket === 'undefined') {
        console.log("浏览器不支持WebSocket...");
        return false
    }
    var settings = {
        url: 'ws://127.0.0.1:9007',
        debug: false,
        reconnectInterval: 1000,
        maxReconnectInterval: 30000,
        reconnectDecay: 1.5,
        timeoutInterval: 2000,
        protocol: null,
        showBar: false,
        applink: "",
        uid: 0
    };
    $.GSWebsocket = function (options) {
        if (!options) {
            options = {}
        }
        for (var key in settings) {
            if (typeof options[key] !== 'undefined') {
                this[key] = options[key]
            } else {
                this[key] = settings[key]
            }
        }
        this.reconnectAttempts = 0;
        this.readyState = WebSocket.CONNECTING;
        this.ws = null;
        var forcedClose = false;
        var timedOut = false;
        this.callbacks = [];
        this.openHandles = [];
        this.closeHandles = [];
        this.open = function (reconnectAttempt) {
            self.ws = new WebSocket(self.url, self.protocol || []);
            if (!reconnectAttempt) {
                self.log("connecting...")
            }
            self.log('GSWebsocket', 'attempt-connect', self.url);
            var localWs = self.ws;
            var timeout = setTimeout(function () {
                self.log('GSWebsocket', 'connection-timeout', self.url);
                localWs.close();
                timedOut = false
            }, self.timeoutInterval);
            self.ws.onopen = function (event) {
                clearTimeout(timeout);
                self.log('GSWebsocket', 'onopen', self.url);
                self.protocol = self.ws.protocol;
                self.readyState = WebSocket.OPEN;
                self.reconnectAttempts = 0;
                reconnectAttempt = false;
                self.listenStatusBar();
                self.log(self.openHandles);
                if (self.openHandles.length > 0) {
                    for (var i = 0; i < self.openHandles.length; i++) {
                        if (typeof self.openHandles[i] !== "undefined") {
                            self.openHandles[i](event)
                        }
                    }
                }
                if (typeof self["onOpen"] !== "undefined") {
                    self["onOpen"](event)
                }
            };
            self.ws.onclose = function (event) {
                clearTimeout(timeout);
                self.log('GSWebsocket', 'onclose', self.url, event);
                self.listenStatusBar();
                self.ws = null;
                if (forcedClose) {
                    self.readyState = WebSocket.CLOSED
                } else {
                    self.readyState = WebSocket.CONNECTING;
                    if (!reconnectAttempt && !timedOut) {
                        self.log('GSWebsocket', 'onclose', self.url)
                    }
                    var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
                    setTimeout(function () {
                        self.open(true)
                    }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout)
                }
                self.log(self.closeHandles);
                if (self.closeHandles.length > 0) {
                    for (var i = 0; i < self.closeHandles.length; i++) {
                        if (typeof self.closeHandles[i] !== "undefined") {
                            self.closeHandles[i](event)
                        }
                    }
                }
                if (typeof self["onClose"] !== "undefined") {
                    self["onClose"](event)
                }
            };
            self.ws.onmessage = function (event) {
                self.log('GSWebsocket', 'onmessage', self.url, event);
                if (event.data) {
                    var data = JSON.parse(event.data);
                    if (data.type == 2) {
                        if ("sid"in data) {
                            if (typeof self.callbacks[data.sid] !== "undefined") {
                                try {
                                    self.callbacks[data.sid](data)
                                } catch (err) {
                                    self.log("callbacks uncall", err.message)
                                }
                            } else {
                                if (typeof self["onMessage"] !== "undefined") {
                                    self["onMessage"](data)
                                } else {
                                    self.log("onMessage unhandle", data)
                                }
                            }
                        } else {
                            if (typeof self["onMessage"] !== "undefined") {
                                self["onMessage"](data)
                            } else {
                                self.log("onMessage unhandle", data)
                            }
                        }
                    } else if (data.type == 1) {
                        if ("action"in data) {
                            var action = "on" + self.ucfirst(data.action);
                            if (typeof self[action] !== "undefined") {
                                self[action](data)
                            } else {
                                self.log("action unhandle", action, data)
                            }
                        } else {
                            self.log("action not set", data)
                        }
                    }
                }
            };
            self.ws.onerror = function (event) {
                self.log('GSWebsocket', 'onerror', self.url, event);
                if (typeof self["onError"] !== "undefined") {
                    self["onError"](event)
                }
            }
        };
        this.bind = function (m, fn) {
            m = "on" + self.ucfirst(m);
            self[m] = fn
        };
        this.openHandle = function (fn) {
            var index = parseInt(self.openHandles.length);
            self.openHandles[index + 1] = fn
        };
        this.closeHandle = function (fn) {
            var index = parseInt(self.closeHandles.length);
            self.closeHandles[index + 1] = fn
        };
        this.log = function () {
            if (self.debug) {
                var count = arguments.length;
                switch (count) {
                    case 5:
                        console.debug(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
                        break;
                    case 4:
                        console.debug(arguments[0], arguments[1], arguments[2], arguments[3]);
                        break;
                    case 3:
                        console.debug(arguments[0], arguments[1], arguments[2]);
                        break;
                    case 2:
                        console.debug(arguments[0], arguments[1]);
                        break;
                    case 1:
                        console.debug(arguments[0]);
                        break;
                    case 0:
                        break
                }
            }
        };
        this.start = function () {
            self.initStatusBar();
            if (self.showBar) {
                self.showStatusBar()
            }
            self.open(false)
        };
        this.send = function (action, params, success, faile) {
            if (self.ws && self.readyState == WebSocket.OPEN) {
                var id = self.uuid();
                var data = {action: action, params: params, sid: id, type: 1, sign: ""};
                self.callbacks[id] = success;
                if (self.debug) {
                    console.debug('GSWebsocket', 'send', self.url, data)
                }
                return self.ws.send(JSON.stringify(data))
            } else {
                if (self.debug) {
                    console.debug('GSWebsocket can not send , websocket is unconnection')
                }
                faile()
            }
        };
        this.close = function (code, reason) {
            if (typeof code == 'undefined') {
                code = 1000
            }
            forcedClose = true;
            if (self.ws) {
                self.ws.close(code, reason)
            }
            self.listenStatusBar()
        };
        this.refresh = function () {
            if (self.ws) {
                self.ws.close()
            }
            self.listenStatusBar()
        };
        this.timestamp = function () {
            return new Date().getTime()
        };
        this.uuid = function () {
            return self.timestamp()
        };
        this.ucfirst = function (str) {
            return str.substring(0, 1).toUpperCase() + str.substring(1)
        };
        this.initStatusBar = function () {
            if (self.debug) {
                console.debug("添加状态浮层...")
            }
            var strMonitor = '<div id="weixin-monitor"></div>';
            $('body').append(strMonitor);
            self.statusBarId = $('#weixin-monitor');
            self.statusBarId.css({
                'position': 'fixed',
                'z-index': 1000,
                'bottom': '30px',
                'right': '16px',
                'width': '47px',
                'height': '58px',
                'background-size': '47px 58px',
                'background-repeat': 'no-repeat',
                'display': 'none'
            });
            self.log("添加提示浮层...");
            var strBubble = '<div id="weixin-bubble"></div>';
            $('body').append(strBubble);
            self.statusBubbleId = $('#weixin-bubble');
            self.statusBubbleId.css({
                'position': 'fixed',
                'z-index': 1000,
                'bottom': '91px',
                'right': '41px',
                'width': '150px',
                'height': '150px',
                'background-position': 'bottom right',
                'background-repeat': 'no-repeat',
                'display': 'none'
            });
            self.log("绑定bar click事件...");
            self.statusBarId.bind('click', function () {
                if (self.statusBubbleId.css('display') == 'none') {
                    self.statusBubbleId.velocity("fadeIn", {duration: 200})
                } else {
                    self.statusBubbleId.velocity("fadeOut", {duration: 200})
                }
                if (self.readyState != WebSocket.OPEN && self.applink) {
                    window.location = self.applink
                }
            })
        };
        this.showStatusBar = function () {
            self.statusBarId.show();
            self.showBar = true
        };
        this.hiddenStatusBar = function () {
            self.statusBarId.hidden();
            self.showBar = false
        };
        this.listenStatusBar = function () {
            if (self.readyState == WebSocket.OPEN) {
                self.statusBarId.css({'background-image': 'url("/img/weixin/onlineIcon@2x.png")'});
                self.statusBubbleId.css({
                    'background-image': 'url("/img/weixin/onlineBubble@2x.png")',
                    'background-size': '100px 44px'
                })
            } else {
                self.statusBarId.css({'background-image': 'url("/img/weixin/offlineIcon@2x.png")'});
                self.statusBubbleId.css({
                    'background-image': 'url("/img/weixin/offlineBubble@2x.png")',
                    'background-size': '100px 44px'
                })
            }
        };
        this.recivedPushTask = function (reload) {
            self.bind("task_result", function (data) {
                if (typeof data.code != "undefined" && data.code == 0) {
                    var tid = data.data.tid;
                    var ls_key = "finished_task_" + self.uid + "_" + tid;
                    if (!localStorage.getItem(ls_key)) {
                        localStorage.setItem(ls_key, 1)
                    } else {
                        $.ajax({
                            url: 'http://m.qianka.com/already/done',
                            data: {task_id: tid},
                            type: 'get',
                            datatype: 'json'
                        });
                        return
                    }
                    $('body').append('<div class="gs-notification"><p></p></div>');
                    $(".gs-notification").find("p").html("您完成限时推荐《" + data.data.task_info.subtitle + "》,获得 <span>" + data.data.task_info.subcurrency + "</span> 金");
                    var h = parseFloat($(".gs-notification").innerHeight());
                    $(".gs-notification").css({"top": -h + "px", "visibility": "visible", "background-size": "100%"});
                    var closeTime = 300;

                    function closeNotification() {
                        $('.gs-notification').velocity("finish");
                        $('.gs-notification').velocity({'top': -h}, {duration: closeTime});
                        setTimeout(function () {
                            $('.gs-notification').velocity("finish");
                            $(".gs-notification").remove();
                            if (reload) {
                                window.location.reload()
                            }
                        }, 1000)
                    }

                    $(".gs-notification").show();
                    $(".gs-notification").click(function () {
                        closeTime = 300;
                        closeNotification()
                    });
                    $('.gs-notification').velocity({'top': 0}, {duration: 300});
                    setTimeout(closeNotification, 5000)
                } else {
                }
            })
        };
        var self = this;
        return self
    }
})(jQuery);



0
wuyiw
wuyiw

常见的js压缩方式.

你把整个代码, 去掉开头eval(不要去掉括号), 拿去运行, 输出的结果就是源代码.

0
osc特邀摸鱼官
osc特邀摸鱼官
钱咖的代码也被你拿到了
返回顶部
顶部