Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: What Does This Code Do? Supersedes: <1993505.8uK0khNJmU@PointedEars.de> Date: Thu, 10 Dec 2015 00:31 +0100 Organization: PointedEars Software (PES) Lines: 53 Message-ID: <4853393.F10FAma5ux@PointedEars.de> References: <62tg6b5gdt3v9fprpj1runb86d7lsr1f7b@4ax.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1449703861 13397 eJwNyEkBwDAIBEBL3KRyYAP+JaTzHNfgQFp4mK9vGUs3/OhYKGQOtvomZZR8xDtXR+tf4oThASj0EbE= (9 Dec 2015 23:31:01 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 9 Dec 2015 23:31:01 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Key: sha1:kLZftnKWN5Wva/eS0ImdKqQn8Ow= X-User-ID: eJwNwokRwDAIA7CVwmOg4xRM9h+hPQkWEpMeCMf9oYeuXJXtXU1/oMCoMTuQmJ09b9P89eq6V0ystQ5Z9P0AZjoWGg== Cancel-Lock: sha1:usOKGCjc2yviixiyuV0FQ7jA8bw= X-NNTP-Posting-Host: eJwFwQkBwDAIA0BLhLeTw6DxL6F3YYmc8oz0YHCocnkoO9w/t3W9bT8RbBsL55YJAhhFZzw9rRF0 Xref: csiph.com comp.lang.javascript:29004 [This follow-up accidentally went out as an e-mail at first; please ignore that.] Gene Wirchenko wrote: > I suspect that this code was run through a compresser of some > sort. ("3e3" to save a byte over "3000" and the like.) I can > understand bits of it, but I can not parse it in total. This source code was generated by a tool called a “minifier”, which you can deduce from observing that all variable and parameter identifiers are only one character long where the characters have successive Unicode code points (“a”, “b”, “c”, “d”, …). Presumably you have seen this source code in a Web browser. If so, and you have seen it in a script resource (usually with suffix “.js”) as well, you can use the *built-in* developer tools’ “pretty print” feature to make the source code easier readable. For example, in Chrome Dev Tools it is toggled with the “{}” icon in the left bottom corner of the source code pane of the “Sources” tab; in Firefox/Iceweasel it is available as “Auto Prettify Minified Sources” in the Settings menu of the source code pane, and as “Prettify Sources” in its context menu, of the Web Developer Tools (not to be confused with the Web Developer extension [0a]). Firebug 2.0.x [0b] also has the “{}” button; as a point of note, it also has a “Pretty Print” Command in the Command Editor of the Console (triangle buttons) that works if block braces were used, and a “Copy” button that is suited to create (non-minified) one-line code for bookmarklets out of the code in the Command Editor. See also (referred to by the FAQ in the section “Debugging”), section “Debugging Minified JavaScript” there. As indicated, you can then use an editor that supports ECMAScript implementations insofar as that it can refactor a symbol in context to make the source code even easier to understand. Eclipse JSDT [1] is one such editor (Ctrl+1 → “Rename in file”, or Ctrl+2 → R by default), Visual Studio Code (which is available even for Linux, and looks like a Sublime/Atom clone ;-)) is another; Atom can do it with the js-refactor package, and Sublime Text with Multiple Selections (built-in). [0a] [0b] [1] pp. [2] [3] [4] -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.