kejames 學習筆記本

這裡是Kejames的筆記本,歡迎各位網友給予指教,謝謝。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Fiddler2 - JavaScript Beautifier Plugin

Posted on 2007-09-12 15:55  Kejames  阅读(261)  评论(0)    收藏  举报
I think everybody is doing this: you open a Web page and see some nice and tricky effects. Next you start Fiddler2 (which is my favorite tool for Web developers!!) and have a more detailed look in the content transferred from server to the client. Fiddler2 includes an automatic encoding removal which means that you can view text files without having to unzip to content first.

During the last years more and more Web developers have obfuscated their JavaScript files. Have a look following short example:

JsonRequestBuilder=function(b,c){var dynamicScript=new
DynamicScript(b,c);JsonRequest=function(g,h,j,k,l,b,c){var
responseFunc=h;var callback=k;this.Callback=function(j,m){var
readyState=m;var responseObject=null;try{if(m=="loaded"||m==
"complete"){responseObject=eval(responseFunc+"();");eval
("window."+responseFunc+" = null;");}}catch(e){readyState=
"error";}finally{callbac(responseObject,j,readyState);}};this.
rawRequest=dynamicScript.CreateReques(g,j,this.Callback,l,b,c);
this.Execute=function(){this.rawRequest.Execute();};this.
Abort=function(){this.rawRequest.Abort();};};function n
// [...]

Well, would't it be great if obfuscated JavaScript code would be formatted a little bit nicer? Yes, I have done a small test with one of my libraries and created a Fiddler2 plugin. See the results below:

I hope to get the Plugin working correct until end of this week, nearly all types of JavaScript coding are working already. On Friday I will publish a first beta version.


http://weblogs.asp.net/mschwarz/archive/2007/08/01/fiddler2-javascript-beautifier-plugin.aspx

真這的是對常寫JavaScript的人有莫大的幫助,讚啦。