How do you unpack javascript using jsbeautifier in python?
<p>I have this javascript code which I want to unpack and beautify, it looks similar to this:</p>

<pre><code>eval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'^$'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('document.body.innerHTML="&lt;iframe width=\'100%\' scrolling=\'no\' height=\'2500\' frameborder=\'0\' src=\'http://www.exmaple.com\'&gt;";',[],1,''.split('|'),0,{}))
</code></pre>

<p>When I put this into jsbeautifier.org I get:</p>

<pre><code>document.body.innerHTML = "&lt;iframe width='100%' scrolling='no' height='2500' frameborder='0' src='http://www.example.com'&gt;";
</code></pre>

<p>But when I try and use the python library (using jsbeautifier.beautify) it doesn't seem to unpack properly:</p>

<pre><code>print al(function (p, a, c, k, e, r) {
    e = String;
    if ('0'.replace(0, e) == 0) {
        while (c--) r[e(c)] = k[c];
        k = [
            function (e) {
                return r[e] || e
            }
        ];
        e = function () {
            return '^$'
        };
        c = 1
    };
    while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
    return p
}('document.body.innerHTML="&lt;iframe width=\'100%\' scrolling=\'no\' height=\'2500\' frameborder=\'0\' src=\'http://www.example.com\'&gt;";', [], 1, ''.split('|'), 0, {}));
</code></pre>

<p>What am I doing wrong?</p>

<p>EDIT: Python code is:</p>

<pre><code>import jsbeautifier
#script needs to have '\n' at the beginning otherwise jsbeautifier throws an error
script = """\neval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'^$'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('document.body.innerHTML="&lt;iframe width=\'100%\' scrolling=\'no\' height=\'2500\' frameborder=\'0\' src=\'http://www.example.com\'&gt;";',[],1,''.split('|'),0,{}))"""
jsbeautifier.beautify(script)
</code></pre>
