Deobfuscate JS obfuscated script for performing it server-side
<p>How can I deobfuscate a javaScript code? It's <a href="https://auth.gripon.ru/" rel="nofollow noreferrer">here</a> (inside of the very last script tag).</p>

<p>Basically I know what it does (obfuscating the form's login/password name attribute value and adds to the form a hidden input with name='char' and random value, see a related question <a href="https://stackoverflow.com/q/34961422/1230477">here</a>). I want to decode the script to know how it performs obfuscation, so that <strong>I could imitate it server-side</strong> (with php). </p>

<p>This <a href="http://www.ilearnzone.net/2013/10/js-decompress-and-beautifier-decode.html" rel="nofollow noreferrer">tool</a> can't decode it. </p>

<p>I've done some deobfuscation by eveluating <code>hd</code> object. I took the parts of code (separated by semicolon <code>;</code>) and eveluated them:</p>

<pre><code>&lt;script&gt;
    var hd =~[];
    hd={___:++hd,$$$$:(![]+"")[hd],__$:++hd,$_$_:(![]+"")[hd],_$_:++hd,$_$$:({}+"")[hd],$$_$:(hd[hd]+"")[hd],_$$:++hd,$$$_:(!""+"")[hd],$__:++hd,$_$:++hd,$$__:({}+"")[hd],$$_:++hd,$$$:++hd,$___:++hd,$__$:++hd};

    hd.$_=(hd.$_=hd+"")[hd.$_$]+(hd._$=hd.$_[hd.__$])+(hd.$$=(hd.$+"")[hd.__$])+((!hd)+"")[hd._$$]+(hd.__=hd.$_[hd.$$_])+(hd.$=(!""+"")[hd.__$])+(hd._=(!""+"")[hd._$_])+hd.$_[hd.$_$]+hd.__+hd._$+hd.$;

    hd.$$=hd.$+(!""+"")[hd._$$]+hd.__+hd._+hd.$+hd.$$;  

    hd.$=(hd.___)[hd.$_][hd.$_];  

    console.log('hd: '); 
    console.dir(hd);
    console.log('hd length: ' + Object.keys(hd).length);
&lt;/script&gt;
</code></pre>

<p>The output of it you might see <a href="http://tarex.ru/testdir/designio/test.html" rel="nofollow noreferrer">there</a> in browser console.</p>

<p>Yet the last part of the code, obviously is a function calling itself: </p>

<pre><code>hd.$(hd.$(... _+"\"")())(); 
</code></pre>

<p><code>hd.$</code> is object's function, see the figure:
<a href="https://i.stack.imgur.com/sQwdl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sQwdl.jpg" alt="enter image description here"></a> </p>

<p>But I do not know how to decode it. 
I've tried to replace all the instances of the object, ex. hd.$$$$, hd.$_$ etc. in the rest of the code but the result is only like <a href="http://tarex.ru/testdir/designio/result.html" rel="nofollow noreferrer">this</a>. No clue how to move on.</p>