Pack. wsf
Copy codeThe Code is as follows: <job>
<! -- Windows Scripting Host command line wrapper for Pack. js -->
<! -- Run as CScript // nologo infile> outfile -->
<Script type = "text/javascript">
Function ICommon (that) {if (that! = Null) {that. inherit = Common. prototype. inherit; that. specialize = Common. prototype. specialize} return that}; ICommon. specialize = function (p, c) {if (! P) p = {}; if (! C) c = p. constructor; if (c == {}. constructor) c = new Function ("this. inherit () "); c. valueOf = new Function ("return this"); c. valueOf. prototype = new this. valueOf; c. valueOf. prototype. specialize (p); c. prototype = new c. valueOf; c. valueOf. prototype. constructor = c. prototype. constructor = c; c. ancestor = this; c. specialize = arguments. callee; c. ancestorOf = this. ancestorOf; return c}; ICommon. valueOf = new Function ("return this"); ICommon. ValueOf. prototype = {constructor: ICommon, inherit: function () {return arguments. callee. caller. ancestor. apply (this, arguments)}, specialize: function (that) {if (this = this. constructor. prototype & this. constructor. specialize) {return this. constructor. valueOf. prototype. specialize (that)} for (var I in that) {switch (I) {case "constructor": case "toString": case "valueOf ": continue} if (typeof that [I] = "function" & that [I]! = This [I]) {that [I]. ancestor = this [I]} this [I] = that [I]} if (that. toString! = This. toString & that. toString! = {}. ToString) {that. toString. ancestor = this. toString; this. toString = that. toString} return this }}; function Common () {}; this. common = ICommon. specialize ({constructor: Common, toString: function () {return "[common" + (this. constructor. className | "Object") + "]"}, instanceOf: function (klass) {return this. constructor = klass | klass. ancestorOf (this. constructor) }}); Common. className = "Common"; Common. ancestor = null; Common. ances TorOf = function (klass) {while (klass & klass. ancestor! = This) klass = klass. ancestor; return Boolean (klass)}; Common. valueOf. ancestor = ICommon; function ParseMaster () {var E = 0, R = 1, L = 2; var G =/\ (/g, S =/\ $ \ d /, I =/^ \ $ \ d + $/, T =/(['"]) \ 1 \ + (. *) \ + \ 1 \ 1 $/, ES = /\\. /g, Q =/'/, DE =/\ x01 [^ \ x01] * \ x01/g; var self = this; this. add = function (e, r) {if (! R) r = ""; var l = (_ 14 (String (e )). match (G) | ""). length + 1; if (S. test (r) {if (I. test (r) {r = parseInt (r. slice (1)-1} else {var I = l; var q = Q. test (_ 14 (r ))? '"':" '"; While (I) r = r. split ("$" + I --). join (q + "+ a [o +" + I + "] +" + q); r = new Function ("a, o ", "return" + q + r. replace (T, "$1") + q) }}_ 31 (e | "/^ $/", r,l?#this.exe c = function (s) {_ 3. length = 0; return _ 28 (_ 5 (s, this. escapeChar ). replace (new RegExp (_ 1, this. ignoreCase? "Gi": "g"), _ 29), this. escapeChar ). replace (DE, "")}; this. reset = function () {_ 1. length = 0}; var _ 3 = []; var _ 1 = []; var _ 30 = function () {return "(" + String (this [E]). slice (1,-1) + ")"}; _ 1. toString = function () {return this. join ("|")}; function _ 31 () {arguments. toString = _ 30; _ 1 [_ 1. length] = arguments} function _ 29 () {if (! Arguments [0]) return ""; var I = 1, j = 0, p; while (p = _ 1 [j ++]) {if (arguments [I]) {var r = p [R]; switch (typeof r) {case "function": return r (arguments, I); case "number ": return arguments [r + I]} var d = (arguments [I]. indexOf (self. escapeChar) =-1 )? "": "\ X01" + arguments [I] + "\ x01"; return d + r} else I + = p [L] }}; function _ 5 (s, e) {return e? S. replace (new RegExp ("\" + e + "(.) "," g "), function (m, c) {_ 3 [_ 3. length] = c; return e}): s}; function _ 28 (s, e) {var I = 0; return e? S. replace (new RegExp ("\" + e, "g"), function () {return e + (_ 3 [I ++] | "")}): s}; function _ 14 (s) {return s. replace (ES, "") }}; ParseMaster. prototype = {constructor: ParseMaster, ignoreCase: false, escapeChar: ""}; function pack (_ 7, _ 0, _ 2, _ 8) {var I = "$1"; _ 7 + = "\ n"; _ 0 = Math. min (parseInt (_ 0), 95); function _ 15 (s) {var I, p; for (I = 0; (p = _ 6 [I]); I ++) {s = p (s)} return s}; var _ 25 = function (p, a, c, k, e, d) {while (c --) if (k [c]) p = p. replace (new RegE Xp ('\ B' + e (c) + '\ B', 'G'), k [c]); return p }; var _ 26 = function () {if (! ''. Replace (/^/, String) {while (c --) d [e (c)] = k [c] | e (c ); k = [function (e) {return d [e]}]; e = function () {return '\ w +'}; c = 1 }}; var _ 6 = []; function _ 4 (p) {_ 6 [_ 6. length] = p}; function _ 18 (s) {var p = new ParseMaster; p. escapeChar = "\"; p. add (/'[^' \ n \ r] * '/, I); p. add (/"[^" \ n \ r] * "/, I); p. add (/\/[^ \ n \ r] * [\ n \ r]/, ""); p. add (// \/\ * [^ *] * \ * + ([^ \/] [^ *] * \ * + )*\//,""); p. add (/\ s + (\/[^ \/\ n \ r \ *] [^ \/\ n \ r] * \/g? I ?) /, "$2"); p. add (/[^ \ w \ x24 \/'"*)\? :] \/[^ \/\ N \ r \ *] [^ \/\ n \ r] * \/g? I? /, I); if (_ 8) p. add (/; [^ \ n \ r] + [\ n \ r]/); p. add (/\ (; \)/, I); p. add (/; + \ s * ([};])/, "$2" using s0000p.exe c (s); p. add (/(\ B | \ x24) \ s + (\ B | \ x24)/, "$2 $3"); p. add (/([+ \-]) \ s + ([+ \-])/, "$2 $3"); p. add (/\ s +/, ""); return p.exe c (s)}; function _ 17 (s) {var p = new ParseMaster; p. add (/(\ x24 +) ([a-zA-Z _] +) (\ d *)/, function (m, o) {var l = m [o + 2]. length; var s = l-Math.max (l-m [o + 3]. length, 0); return m [o + 1]. substr (s, l) + m [o + 4]}); var r =/\ B _ [A-Za-z \ d] \ W */; var k = _ 13 (s, _ 9 (r), _ 21); var e = k. e; p. add (r, function (m, o) {return e [m [o]}); return p.exe c (s)}; function _ 16 (s) {if (_ 0> 62) s = _ 20 (s); var p = new ParseMaster; var e = _ 12 (_ 0 ); var r = (_ 0> 62 )? /\ W +/:/\ w +/; k = _ 13 (s, _ 9 (r), e); var e = k. e; p. add (r, function (m, o) {return e [m [o]}); return s&&_27(p.exe c (s), k)}; function _ 13 (s, r, e) {var a = s. match (r); var so = []; var en = {}; var pr = {}; if (a) {var u = []; var p = {}; var v = {}; var c = {}; var I =. length, j = 0, w; do {w = "$" + a [-- I]; if (! C [w]) {c [w] = 0; u [j] = w; p ["$" + (v [j] = e (j)] = j ++} c [w] ++} while (I); I = u. length; do {w = u [-- I]; if (p [w]! = Null) {so [p [w] = w. slice (1); pr [p [w] = true; c [w] = 0} while (I); u. sort (function (m1, m2) {return c [m2]-c [m1]}); j = 0; do {if (so [I] = null) so [I] = u [j ++]. slice (1); en [so [I] = v [I]} while (++ I <u. length)} return {s: so, e: en, p: pr }}; function _ 27 (p, k) {var E = _ 10 ("e \ (c \)", "g"); p = "'" + _ 5 (p) + "'"; var a = Math. min (k. s. length, _ 0) | 1; var c = k. s. length; for (var I in k. p) k. s [I] = ""; k = "'" + k. s. join ("|") + "'. split ('|') "; var e = _ 0> 62? _ 11: _ 12 (a); e = String (e ). replace (/_ 0/g, ""). replace (/arguments \. callee/g, "e"); var I = "c" + (a> 10? ". ToString (a) ":" "); if (_ 2) {var d = _ 19 (_ 26); if (_ 0> 62) d = d. replace (// \\\\ w/g, "[\\ xa1-\\ xff]"); else if (a <36) d = d. replace (E, I); if (! C) d = d. replace (_ 10 ("(c) \ s * = \ s * 1"), "$1 = 0")} var u = String (_ 25 ); if (_ 2) {u = u. replace (/\ {/, "{" + d + ";")} u = u. replace (/"/g," '"); if (_ 0> 62) {u = u. replace (/'\ B' \ s * \ + | \ + \ s * '\ B'/g ,"")} if (a> 36 | _ 0> 62 | _ 2) {u = u. replace (/\ {/, "{e =" + e + ";")} else {u = u. replace (E, I)} u = pack (u, 0, false, true); var p = [p, a, c, k]; if (_ 2) {p = p. concat (0, "{}")} return "eval (" + u + "(" + p + ") \ n"}; function _ 12 () {return a> 10? A> 36? A> 62? _ 11: _ 22: _ 23: _ 24}; var _ 24 = function (c) {return c}; var _ 23 = function (c) {return c. toString (36)}; var _ 22 = function (c) {return (c <_ 0? '': Arguments. callee (parseInt (c/_ 0) + (c = c % _ 0)> 35? String. fromCharCode (c + 29): c. toString (36)}; var _ 11 = function (c) {return (c <_ 0? '': Arguments. callee (c/_ 0) + String. fromCharCode (c % _ 0 + 161)}; var _ 21 = function (c) {return "_" + c}; function _ 5 (s) {return s. replace (/([\ '])/g, "\ $1")}; function _ 20 (s) {return s. replace (/[\ xa1-\ xff]/g, function (m) {return "\ x" + m. charCodeAt (0 ). toString (16)}; function _ 10 (s, f) {return new RegExp (s. replace (/\ $/g, "\ $"), f)}; function _ 19 (f) {with (String (f )) return slice (indexOf ("{") + 1, lastIndexOf ("}")}; function _ 9 (r) {return new RegExp (String (r ). slice (1,-1), "g")}; _ 4 (_ 18); if (_ 8) _ 4 (_ 17); if (_ 0) _ 4 (_ 16); return _ 15 (_ 7 )};
</Script>
<Script type = "text/javascript">
Var VERSION = '1. 0.0 ';
Var AUTHOR = 'rob seiler';/* seiler@elr.com.au */
/* Get command line arguments */
Function JS_getArgs (){
Var args = [];
Var objArgs = WScript. Arguments;
If (objArgs. length> 0 ){
For (var I = 0; I <objArgs. length; I ++ ){
Args [I] = objArgs (I);/* sic-index in "()"-an object, not an array! */
}
}
Return (args );
}
/* Read the input file */
Function JS_readFile (fname ){
Var s = '';
Var ForReading = 1;
Var fso = new ActiveXObject ("Scripting. FileSystemObject ");
Var ts = fso. OpenTextFile (fname, ForReading );
While (! Ts. AtEndOfStream ){
S + = ts. ReadLine () + '\ n ';
}
Ts. Close ();
Return (s );
}
/* Show help if needed-eg 0 command line arguments */
Function JS_Help (){
WScript. Echo ('compress and encode a Javascript source file using Dean Edwards "Packer "');
WScript. Echo ('version: '+ Version );
WScript. Echo ('syntax: program sourcefile [_ encoding] [_ fastDecode] [_ specialChars] \ n ');
}
/* Main program: Get arguments; read input file; output packed string */
Function main (){
Var params = [];
Params = JS_getArgs ();
Params [1] = (typeof (params [1]) = 'undefined ')? 62: params [1]; //-dean: changed defaults
Params [2] = (typeof (params [2]) = 'undefined ')? 1: params [2];
Params [3] = (typeof (params [3]) = 'undefined ')? 0: params [3];
If (params [0]> ''){
Var $ script = JS_readFile (params [0]);
If ($ script> ''){
$ Script = pack ($ script, params [1], params [2], params [3]);/* Returns the Dean Edwards "packed" string */
WScript. Echo ($ script );
}
Else {JS_Help ();}
}
Else {JS_Help ();}
}
/* Do the job */
Main ();
</Script>
</Job>
Test. bat
Copy codeCode: CScript/nologo pack. wsf test. js> test-p.js