简体   繁体   中英

javascript code analysis: getting the name of handler

I am to analyse a huge js script. I'm using deobfuscators and firebug, but this script is so complicated that it's difficult for me to understand anything. So my question is do you know any tool that would show me eg name of function that handles event I fire? Or maybe it's possible to write it myself?

Try (this pattern)

$(function () {
    $(document).on("click.abc", "body", function def (e) {
        var name = (e.handleObj.handler.name === "" 
                    ? "<i>event handler name:</i> " + "anonymous function"
                    : "<i>event handler name:</i> "+ e.handleObj.handler.name);
        var namespace =  (e.handleObj.namespace 
                          ? "<i>event namespace:</i> " + e.handleObj.namespace 
                          : "<i>event namespace:</i> " + e.handleObj.namespace);
        $("body").append("<br>" 
                         + "<i>event type:</i> " 
                         + e.type + "\n" 
                         + name + "\n" 
                         + namespace);
        $.each($._data($(document)[0], "events"), function(k, v) {
          console.log(k
                      , v[0].data
                      , v[0].guid
                      , v[0].handler.name
                      , v[0].namespace
                      , v[0].origType
                      , v[0].selector
                      , v[0].type);
        });
    });
});

jsfiddle http://jsfiddle.net/guest271314/ykcnbuqp/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM