是否有插件可以让我自动取消包含在网站上的 Javascript?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4279319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a plugin that allows me to automatically unminify the Javascript included on a site?
提问by Henrik Heimbuerger
Is there a plugin, add-on, Greasemonkey script or something similar (at worst, an easy to use proxy?) that automatically unminifiesthe Javascript files included on a site?
是否有插件、附加组件、Greasemonkey 脚本或类似的东西(最糟糕的是,一个易于使用的代理?)可以自动取消包含在站点中的 Javascript 文件?
I know about e.g. jsbeautifier.orgbut doing this externally doesn't allow me to set breakpoints in the unminified code, for example.
我知道例如jsbeautifier.org但在外部执行此操作不允许我在未缩小的代码中设置断点,例如。
Typical use cases for me:
我的典型用例:
- Analysing and learning from complex web frontends.
- Debugging Greasemonkey scripts which interact with the existing code.
- 分析和学习复杂的 Web 前端。
- 调试与现有代码交互的 Greasemonkey 脚本。
I'm primarily interested in a solution that works with Firebug, but if there's something for the dev tools of Chrome or Opera, I'd like to hear about it as well.
我主要对适用于 Firebug 的解决方案感兴趣,但如果有适用于 Chrome 或 Opera 的开发工具的东西,我也想听听。
采纳答案by Matthew Kelly
In chrome 13+, there is 'pretty print'.
在 chrome 13+ 中,有“漂亮的打印”。
- Right click 'inspect element'
- Go to Script tab
- Click the curly braces in the bottom right.
- 右键单击“检查元素”
- 转到脚本选项卡
- 单击右下角的花括号。


回答by B T
Someone has made JSBeautifier into a Firebug plugin:
有人把JSBeautifier做成了Firebug插件:
https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/
https://addons.mozilla.org/en-US/firefox/addon/javascript-deminifier/
This has made my day today!
这让我今天很开心!
回答by Annie
VenkmanJavaScript debugger has a pretty-printer.
VenkmanJavaScript 调试器有一个漂亮的打印机。
There is also an extensionfor Fiddler proxy.
Fiddler 代理还有一个扩展。
IE9 developer tools also have a "format javascript" option (see "F12 Developer Tools and Formatting Minified Script" here)
IE9 开发人员工具也有一个“格式化 javascript”选项(请参阅此处的“F12 开发人员工具和格式化缩小脚本” )
回答by kmote
FYI - the same functionality is available in IE9's F12 Developer Tools: With script tab open, select the hammer/wrench button on the button bar ("Configuration"), and select "Format JavaScript".
仅供参考 - IE9 的 F12 开发人员工具中提供了相同的功能:打开脚本选项卡,选择按钮栏上的锤子/扳手按钮(“配置”),然后选择“格式化 JavaScript”。
回答by Henrik Heimbuerger
Webkit/Chromium can now do this as well, see Webkit Bug 57942, Changeset 83713and Peter Beverloo's change summary post mentioning this.
Webkit/Chromium 现在也可以这样做,请参阅Webkit 错误 57942、变更集 83713和Peter Beverloo 的变更摘要帖子中提到了这一点。
Don't ask me starting with which version of Chromium/Chrome this is available, but feel free to mention here if you do know. :)
不要问我从哪个版本的 Chromium/Chrome 开始可用,但如果您知道,请随时在此处提及。:)
回答by calvinf
If the script is only minified for whitespace, some of the solutions offered may work. As you mention, JSBeautifier is a useful tool.
如果脚本仅针对空白进行了缩小,则提供的某些解决方案可能会起作用。正如您所提到的,JSBeautifier 是一个有用的工具。
However, if the JavaScript you're looking at has been compressed with a tool such as YUI Compressoror Google Closure Compiler, the variables are going to be shortened and harder to understand.
但是,如果您正在查看的 JavaScript 已经使用诸如YUI Compressor或Google Closure Compiler 之类的工具进行了压缩,那么变量将被缩短并且更难理解。
To see this in action, compare the minified and unminified versions of jQuery (minified version uses Closure Compiler).
要查看实际效果,请比较 jQuery 的缩小版和未缩小版(缩小版使用 Closure Compiler)。
- original: https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js
- minified: https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
- 原文:https: //ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js
- 缩小:https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
For the goal of learning JavaScript, I recommend learning from libraries and plugins written by some of the best JavaScript developers out there. Look at the source code for jQuery, YUI, Moo Tools. Look at code on GitHub by people like John Resigor Thomas Fuchs. Read DailyJsand look at his examples.
为了学习 JavaScript,我建议从一些最好的 JavaScript 开发人员编写的库和插件中学习。查看jQuery、YUI、Moo Tools的源代码。查看 GitHub 上由John Resig或Thomas Fuchs等人编写的代码。阅读DailyJs并查看他的示例。
I hope some of these tools help you in the process of learning. These are the resources that have helped me most.
我希望其中一些工具可以帮助您在学习过程中。这些是对我帮助最大的资源。
回答by JessyNinja
Is not possible with current tools. Show eval scripts is the most you can get. Jsbeautifier.org is nice openthing, and someone can integrate it info firebug.
使用当前工具无法实现。显示 eval 脚本是您可以获得的最多内容。Jsbeautifier.org 是一个很好的开放的东西,有人可以将它集成到 firebug 中。
回答by 3rik82
PrettyPrint is a nice chrome extension for this, it automatically unminifies js in a heartbeat while using regular (Ctrl-U) source.
PrettyPrint 是一个很好的 chrome 扩展,它在使用常规 (Ctrl-U) 源时自动在心跳中取消缩小 js。
You can get it here:
你可以在这里得到它:
https://chrome.google.com/webstore/detail/prettyprint/nipdlgebaanapcphbcidpmmmkcecpkhg/
https://chrome.google.com/webstore/detail/prettyprint/nipdlgebaanapcphbcidpmmmkcecpkhg/

