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.ancestorOf=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=/\\https://www.jb51.net/article/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.exec=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 RegExp(‘\\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″);s=p.exec(s);p.add(/(\b|\x24)\s+(\b|\x24)/,”$2 $3″);p.add(/([+\-])\s+([+\-])/,”$2 $3″);p.add(/\s+/,””);return p.exec(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.exec(s)};function _16(s){if(_0>62)s=_20(s);var p=new ParseMaster;var e=_12(_0);var r=(_0>62)?/\w\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.exec(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=a.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
var VERSION = ‘1.0.0’;
var AUTHOR = ‘Rob Seiler’;
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);
}
}
return (args);
}
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);
}
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’);
}
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]);
WScript.Echo ($script);
}
else {JS_Help();}
}
else {JS_Help();}
}
main();