亲宝软件园·资讯

展开

javascript之ESC(第二类混淆)

人气:0
ESC(第二类混淆)
GNU项目
http://www.saltstorm.nethttps://img.qb5200.com/download-x/downloads/esc/ESC.zip

将以下代码保存为
ESC.wsf
复制代码 代码如下:

<?xml version="1.0"?>
<!-- Generated by Soya.IO.WSFFactory v0.95 [Sun, 6 Feb 2005 20:19:57 UTC] -->
<package>
<job>
<?job error="false" debug="false" ?>
<resource id="about">
-----------------------------------------------------------------------------
  ESC (ECMAScript Cruncher)
  * Version       : 1.13
  * Date          : 2005-02-06 21:19:57 [+0100]
  * License       : GNU GPL (http://www.gnu.org/copyleft/gpl.txt)
  * Copyright (C) 2001-2005 Thomas Loo <tloo@saltstorm.net>

  ---------------------------------------------------------------------------
  ESC is an ECMAScript(*) pre-processor enabling an unlimited number of
  external scripts to be compressed/crunched into tight, bandwidth-optimized
  packages. ESC supports compressing of external sources only. Trying to
  process scripts inlined in HTML, ASP, PHP or equivalent pages are NOT
  recommended with this version of ESC. This feature might be added in a
  future version. Type "cscript ESC.wsf -help" for usage instructions.

  ESC is built using components from the Soya Scripting API 1.0.0-b10,
  a uni-host/cross-browser ECMAScript compliant class-library distributed
  freely under the terms of the BSD License. The Soya Scripting API,
  'lib-soya' and the Soya SDK can be found at http://www.saltstorm.net/
  ---------------------------------------------------------------------------
  * ECMAScript is the international standard for javascript.
-----------------------------------------------------------------------------
</resource>

<resource id="copyright">
-----------------------------------------------------------------------------

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-----------------------------------------------------------------------------

</resource>

<resource id="usage">
------------------------------------------------------------------------------
 Usage: cscript ESC.wsf -l [0-4] -ow output.js foo.js bar.js C:\scripts\baz...
 -----------------------------------------------------------------------------
  -a  [-about]             : Description page
  -c  [-copyright]         : Copyright/license notice
  -e  [-example]           : Examples of usage
  -h  [-help]              : This help-screen
 -----------------------------------------------------------------------------
  -l  [-level]   [01(2)34] : [optional] Set crunch-level (4 sets -$ on)
  -s  [-silent]            : [optional] Run silent, nada stdout
  -v  [-verbose]           : [optional] Run in verbose mode
  -$                       : [optional] Activate variable-substitution engine
 -----------------------------------------------------------------------------
  -oa <filename>           : Target filename for appending
  -ow <filename>           : Target filename for writing
  -ow STDOUT               : Write stream to STDOUT
 -----------------------------------------------------------------------------
 <input-file(s)>           : [required]
  file(s) and/or directories containing scripts to crunch...
  (paths containing spaces must be quoted)
</resource>

<resource id="example">
-----------------------------------------------------------------------------
 Examples of usage.

  Crunch 'original1.js','original2.js' and 'original3.js' at
  level 2 (default) and save the output as 'crunched.js'.
  Any previous file named 'crunched.js' will be overwritten.
   X:\cscript ESC.wsf -ow crunched.js original1.js original2.js original3.js
  ---------------------------------------------------------------------------

  Grab all scriptfiles (.js) in directory 'C:\script-directory' and crunch
  them at level 1 (comment and empty line removal only) and append the result
  to 'crunched.js'. If 'crunched.js' doesn't exist, it will be created.
   X:\cscript ESC.wsf -l 1 -oa crunched.js C:\script-directory
  ---------------------------------------------------------------------------

  Subject 'original1.js' and 'original2.js' for variable substitution,
  but perform no comment or whitespace removal.
  Redirect output to STDOUT instead of writing to file.
   X:\cscript ESC.wsf -l 0 -$ -ow STDOUT original1.js original2.js
  ---------------------------------------------------------------------------

  Crunch 'original.js' using variable substitution and remove
  any occurance of whitespace (where permitted...)
  and save it as 'crunched.js' (equals -l 3 -$)
   X:\cscript ESC.wsf -l 4 -ow crunched.js original.js
  ---------------------------------------------------------------------------

 Try 'ESC.wsf -help' for information about available run-time directives.
-----------------------------------------------------------------------------
</resource>

<resource id="wscript">
ESC must be run from a DOS command prompt under    
cscript.exe. Do you want to switch host and have
ESC bring up a helpscreen ?

</resource>

<resource id="jscript">
ESC needs JScript 5.5 or higher to score...
You need to update your version of JScript to run ESC.
Read the 'Requirements' section in the manual for information
how to obtain and install the latest version of Microsofts
'Windows Script' package.

</resource>

<resource id="common.map">

Anchor
ActiveXObject
Call
Closure
Components
Dictionary
Document
DOMParser
Embed
EvalError
Event
Form
Global
HttpCookie
Image
JavaArray
JavaClass
JavaMethod
JavaObject
JavaPackage
Layer
MimeType
MimeTypeArray
Option
Url
Packages
Plugin
PluginArray
Popup
RangeError
ReferenceError
TypeError
StyleClass
StyleSelector
SyntaxError
TypeError
WScript
URIError
XMLHttpRequest
XMLSerializer
XPathEvaluator
XSLTDocument
XSLTProcessor
Attr
CDATASection
CharacterData
Comment
CSS2Properties
DOMException
DOMImplementation
DocumentType
Element
EntityReference
EvalError
NamedNodeMap
Node
NodeList
Notation
ProcessingInstruction
Text
HTMLElement
HTMLDocument
HTMLCollection
HTMLHtmlElement
HTMLHeadElement
HTMLLinkElement
HTMLTitleElement
HTMLMetaElement
HTMLBaseElement
HTMLIsIndexElement
HTMLStyleElement
HTMLBodyElement
HTMLFormElement
HTMLSelectElement
HTMLOptGroupElement
HTMLOptionElement
HTMLInputElement
HTMLTextAreaElement
HTMLButtonElement
HTMLLabelElement
HTMLFieldSetElement
HTMLLegendElement
HTMLUListElement
HTMLOListElement 
HTMLDListElement
HTMLDirectoryElement
HTMLMenuElement
HTMLLIElement
HTMLBlockquoteElement 
HTMLDivElement
HTMLParagraphElement
HTMLHeadingElement
HTMLQuoteElement
HTMLPreElement
HTMLBRElement
HTMLBaseFontElement 
HTMLFontElement
HTMLHRElement
HTMLModElement 
HTMLAnchorElement
HTMLImageElement
HTMLObjectElement
HTMLParamElement
HTMLAppletElement
HTMLMapElement
HTMLAreaElement
HTMLScriptElement
HTMLTableElement
HTMLTableCaptionElement
HTMLTableColElement
HTMLTableSectionElement
HTMLTableRowElement
HTMLTableCellElement
HTMLFrameSetElement
HTMLFrameElement
HTMLIFrameElement
_newEnum
alert
atob
attachEvent
back
btoa
captureEvents
clearTimeout
clearInterval
close
CollectGarbage
confirm
createEventObject 
createPopup
decodeURI
decodeURIComponent
detachEvent
dump
encodeURI
encodeURIComponent
escape
eval
execScript
find
forward
frameElement
getAttention
GetAttention
getClass
getComputedStyle
getResource
GetObject
home
isFinite
isNaN
moveBy
moveTo
open
openDialog
parseInt
parseFloat
print
prompt
releaseEvents
resizeBy
resizeTo
ScriptEngine
ScriptEngineMajorVersion
ScriptEngineMinorVersion
ScriptEngineBuildVersion    
scroll
scrollBy
scrollByLines
scrollByPages
scrollIntoView
scrollTo
setCursor
setInterval
setTimeout
showHelp
showModalDialog
showModelessDialog
sizeToContent
stop
taint
toString
updateCommands
unescape
untaint
valueOf
_content
appCore
arguments
arity
callee
caller
clientInformation
clipboardData
closed
constructor
controllers
crypto
debug
defaultStatus
directories
document
element
event
external
history
forward
frames
Infinity
innerHeight
innerWidth
java
length
loading
location
locationbar
name
menubar
navigator
netscape
offscreenBuffering
opener
opera
outerHeight
outerWidth
pageXOffset
pageYOffset
parent
personalbar
pkcs11
prompter
prototype
returnValue
screen
screenLeft
screenTop
screenX
screenY
scrollX
scrollY
scrollbars
self
sidebar
status
statusbar
style
sun
title
toolbar
top
window
onafterprint
onbeforeprint
onbeforeunload
onblur
onchange
onclick
onclose
onerror
onfocus
onhelp
onload
onresize
onreset
onscroll
onselect
onunload
onmousedown
onmouseup
onmouseover
onmouseout
onkeydown
onkeyup
onkeypress
onmousemove
onsubmit
onreset
onchange
onselect
onclose
onabort
onerror
onpaint
ondragdrop
Soya
BOOTSTRAP
</resource>

<resource id="core.map">

abstract
break
continue
const
class
catch
case
debugger
default
double
delete
do
enum
extends
else
function
finally
float
false
for
get
instanceof
implements
import
int
in
if
long
null
new
protected
private
package
public
return
switch
static
super
set
typeof
throw
true
this
try
undefined
void
var
while
with
getter
setter
__defineGetter__
__defineSetter__
end
elif 
cc_on 
_win32
_win16
_mac
_alpha
_x86
_mc680x0
_PowerPC
_jscript
_jscript_build
_jscript_version
Array
Boolean
Date
Enumerator
Error
Function
Math
Number
Object
RegExp
String
VBArray

</resource>

<script language="JScript">
<![CDATA[
/*** <POD [ESCtool] (Soya/1.0.0-b10; crlvl:2/1; Sun, 6 Feb 2005 20:19:58 UTC)> ***/
/**
Proving that ESC actually can handle name-mangling and as a general self-sanity
 check, ESC has been used to compress itself along with other required Soya-beans
 while creating the package you see below. To examine these beans in a more human
 readable form, get the latest distribution of the Soya API.
**/
function Soya_API($h)
{
this.name='Soya';
this.version='1.0.0-b10';
this.type='static';
this.debug=0;
this.host=$h;
this.libPath='/lib-soya/';
this.podPath='pods';
this.resourcePath='resources';
this.attachBean=$a;
this.declareBean=$b;
this.registerBean=$c;
this.BeanPrototype=Soya_BeanPrototype;
this.beans=new Object();
this.beans.all=new Array();
Soya_Loader.prototype=new this.BeanPrototype();
this.Loader=new Object();
this.Loader.orphans=new Array();
this.Loader.callbacks=new Object();
this.declareBean('Soya.BeanPrototype',null,this.name,false,true);
}
function Soya_VirtualBean(){}
function Soya_BeanPrototype(){
this.name='Soya.BeanPrototype';
}
function $a($i){
if(!$i.virtual){
eval($i.mutexName).prototype=$i;
eval($i.name+'='+(!$i.constructable?'new ':' ')+
$i.mutexName+(!$i.constructable?'()':''));
}
else eval($i.name+'=this.beans["'+$i.name+'"]');
$i.complete=true;
if(this.Loader&&this.Loader.callbacks[$i.name])
this.Loader.callbacks[$i.name](eval($i.name));
}
function $b($j,$k,$l,$m,$n){
var $o=$k?new this.BeanPrototype():new Soya_VirtualBean();
$o.name=$j;
$o.mutexName=$k||'Soya_VirtualBean';
$o.parentName=$l;
$o.iid=0;
$o.stack=new Array();
$o.complete=Boolean($n);
$o.constructable=($k&&!$m);
$o.virtual=!$k;
return(this.beans[$j]=this.beans.all[this.beans.all.length]=$o);
}
function $c($j,$m,$p,i){
var $q;
var $r=$j.split('\x2e');
var $k=$r.join('\x5f');
if(!this.beans[$j]){
if($p){
var $s='';
$q=$r[0];
for(i=1;i<$r.length-1;i++){
$s+=$q;
$q+=('\x2e'+$r[i]);
if(i<=$p&&!this.beans[$q])
this.attachBean(this.declareBean($q,null,$s,true,true));
}
}
$r.length-=$p?$p:1;
$q=$r.join('\x2e');
this.declareBean($j,$k,$q,$m);
if($r.length>1&&!this.beans[$q])
this.Loader.orphans[this.Loader.orphans.length]=this.beans[$j];
else{
this.attachBean(this.beans[$j]);
var $t=new Array();
for(i=0;i<this.Loader.orphans.length;i++)
if(this.Loader.orphans[i].parentName==$j)
this.attachBean(this.Loader.orphans[i]);
else $t[$t.length]=this.Loader.orphans[i];
this.Loader.orphans=$t;
}
}
return Boolean(i)
}
function $d($u){
this.getResourcePath=Function('sName',
"return(Soya.libPath + Soya.resourcePath + '/' + (sName||this.name).split('.').join('/') + '/')");
this.getClass=Function('sName','return eval(Soya.beans[sName || this.name].mutexName)');
this.toString=Function("return('[object ' + (this.name || 'noname') + ']')");
this.getBeanPath=Function('sName',
"return(Soya.libPath + (sName||this.name).split('.').join('/') + '.js')");
this.type='static';
if(!$u){
this.finalize=$f;
this.initialize=$e;
}
}
function $e($v){
this.iid=this.getClass().prototype.iid++;
if(this.stackable)
this.stack[this.iid]=this;
if(!Soya.beans[this.name].initialized){
$v=$v||
Soya.host[Soya.beans[this.name].mutexName+'_initialize'];
if(typeof($v)=='function')
Soya.beans[this.name].initialized=!$v(this.getClass(),this);
}
}
function $f($w){
$w=$w||
Soya.host[Soya.beans[this.name].mutexName+'_finalize'];
if(typeof($w)=='function')
$w(this.getClass(),this);
}
function Soya_Loader(){};
function $g($x,$y,$z){
if(!Soya.fso)
Soya.fso=new ActiveXObject('Scripting.FilesystemObject');
if(Soya.fso.FileExists($x)){
var $i=Soya.fso.GetFile($x),
$A=Soya.fso.OpenTextFile($i.Path),
$B=$A.Read($z||$i.Size);
$A.Close();
return $B;
}
else if(!$y)
return(WScript.Echo(this.name+' '+Soya.version+
'> File Not found: '+$x),WScript.Quit(99));
else return '';
}
Soya_BeanPrototype.prototype=new $d(0);
Soya_VirtualBean.prototype=new $d(1);
Soya_API.prototype=new $d(1);
var Soya=new Soya_API(this);
if(typeof(BOOTSTRAP)=='function')BOOTSTRAP(Soya);
function Soya_Common()
{
this.name='Soya.Common';
this.type='static';
this.version='1.03';
this.dependencies=[];
this.destroy=$E;
this.makeFunction=$G;
this.typematch=$F;
this.getObject=$C;
this.$ih=$H;
Function.prototype.getArguments=$D;
Soya.BeanPrototype.prototype.Extends=
Function('oBean','bOvr','Soya.Common.$ih(oBean, this, bOvr)');
Soya.BeanPrototype.prototype.Implements=
Function('oBean','bOvr','Soya.Common.$ih(this, oBean, bOvr)');
this.interfaces=new Object();
this.interfaces['Scripting.FilesystemObject']=Soya.fso;
}
function $C($I,$J){
if(typeof(this.interfaces[$I])=='undefined'){
if(typeof ActiveXObject=='function'){
Soya.host.msieax=null;
if(typeof Error=='function')
eval('try{Soya.host.msieax=new ActiveXObject("'+$I+'")}catch(e){}');
else{
var $K=String("on error resume next\nself.msieax=CreateObject('"+$I+"'))");
self.execScript($K,'vbscript');
}
if(!$J)
return Soya.host.msieax;
this.interfaces[$I]=Soya.host.msieax;
}
}
return this.interfaces[$I]||void(0);
}
function $D($L){
var $M=[],
$N=(isNaN($L)||$L<1)?
0:Math.min($L,this.arguments.length);
for(;$N<this.arguments.length;$N++)
$M[$M.length]=this.arguments[$N];
return $M;
}
function $E($O){
if($O!=null&&typeof($O)=='object')
for(var $P in $O){
if(typeof($O[$P])=='object'&&$O[$P])
if($O[$P].constructor&&!$O[$P].style){
this.destroy($O[$P]);
delete($O[$P]);
}
else $O[$P]=null;
}
}
function $F($Q,$R){
var $S;
switch(typeof($Q)){
case 'number':$S=2;break;
case 'boolean':$S=4;break;
case 'string':$S=8;break;
case 'function':$S=16;break;
case 'object':$S=32;break;
default:$S=1;break;
}
return Boolean($S&($R||62));
}
function $G($T){
if($T&&this.typematch($T,16))
return $T;
else return Function(($T&&this.typematch($T,8))?$T:'');
}
function $H($U,$V,$W){
for(var $P in $U)
if($P!='name'&&(!$W||typeof($V[$P])=='undefined'))
$V[$P]=$U[$P];
}
if(typeof(Soya)=='object')Soya.registerBean('Soya.Common',true);
function Soya_WSH()
{
this.name='Soya.WSH';
this.type='static';
this.version='0.88';
this.dependencies=['Soya.Common','Soya.WSH.Registry'];
this.osInfo={};
this.arguments={length:0};
this.$09=function($00)
{return $00.length<2?$00:$00.replace(/^\\-/,'-').replace(/\\{2}/g,'\\')};
this.getArgument=function($01){return(this.arguments[$01]||"")}
this.getArguments=$X;
this.getOSInfo=$Z;
this.getShell=$Y;
}
function $X(){
if(!this.arguments.length&&WScript.Arguments.length){
var i,$02,$03=[],$04=new RegExp('^-+');
for(i=0;i<WScript.Arguments.length;i++)
$03[$03.length]=WScript.Arguments.item(i);
for(i=0;i<$03.length;i++){
$02=$03[i].replace($04,'-');
if($02.length>1&&$04.test($02)){
if(typeof $03[i+1]!='undefined'&&!$04.test($03[i+1]))
this.arguments[this.$09($02.replace($04,''))]=
this.$09($03[1+(i++)]);
else this.arguments[this.$09($02.replace($04,''))]=1;
};
else if($02.length)
this.arguments[this.arguments.length++]=this.$09($03[i]);
}
}
return this.arguments;
}
function $Y(){
if(!this.shell)
this.shell=Soya.Common.getObject('WScript.Shell');
return this.shell;
}
function $Z(){
if(this.osInfo.$0a)
return this.osInfo;
var $05=Soya.Common.getObject('Scripting.FilesystemObject'),
$06=this.getShell().ExpandEnvironmentStrings("%SYSTEMROOT%");
this.osInfo.MSIEVersion=Soya.WSH.Registry.regRead('HKLM\\SOFTWARE\\Microsoft\\Internet Explorer\\Version');
this.osInfo.NETVersion=Soya.WSH.Registry.regRead('HKLM\SOFTWARE\Microsoft\.NETFramework\\Version')||-1;
this.osInfo.SPVersion=Soya.WSH.Registry.regRead('HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CSDVersion')||-1;
this.osInfo.JSVersion=parseFloat(ScriptEngineMajorVersion()+'.'+ScriptEngineMinorVersion());
if($05.FolderExists($06+'\\system32'))
$07=$05.GetFileVersion($06+'\\system32\\kernel32.dll');
else if($05.FolderExists($06+'\\system'))
$07=$05.GetFileVersion($06+'\\system\\kernel32.dll');
if($07){
/^(\d)\.(\d+)\.(\d+)\.\d+$/.test($07);
this.osInfo.majorVersion=parseInt(RegExp.$1);
this.osInfo.minorVersion=parseInt(RegExp.$2,10);
this.osInfo.buildVersion=parseInt(RegExp.$3,10);
this.osInfo.version=$07;
var $08={
'4.00.950':'Win95',
'4.00.1111':'Win95 OSR2',
'4.00.1381':'WinNT',
'4.10.1998':'Win98',
'4.10.2222':'Win98SE',
'4.90.3000':'WinME',
'5.0.2195':'Win2K',
'5.10.2600':'WinXP'
};
this.osInfo.name=$08[$07.replace(/\.\d+$/,'')]||'unknown';
}
this.osInfo.$0a=1;
return this.osInfo;
}
if(typeof(Soya)=='object')Soya.registerBean('Soya.WSH',true);
function Soya_Saltstorm_ESC($0s,$0t,$0u,$y)
{
this.name='Soya.Saltstorm.ESC';
this.version='1.13';
this.type='constructor';
this.dependencies=['Soya.Common','Soya.ECMA.Array'];
this.resourcePath=$0u||'';
this.crunchLevel=$0s||2;
this.substitute=false;
this.verbose=$0t;
this.silent=($y||typeof window=='object');
this.initialize();
this.flush();
}
function Soya_Saltstorm_ESC_initialize($0v,$0w){
$0x=$0w;
var $0y="(?:\"{2}|'{2}|\".*?.\"|'.*?.'|\\/(?!\\*|\\/)..*?\\/)";
var $0z="[-!%&;<=>~:\\/\\^\\+\\|\\,\\(\\)\\*\\?\\[\\]\\{\\}]+";
var $0A="\\/\\*(?!@).(?:.|\\n)*?\\*\\/|\\/\\/.*";
var $0B="\".*?.\"|'.*?.'|\\s*\\/{2,}.*\\n";
var $0C="\\}[\\s\\n]*?([^;,ce\\|\\.\\]\\)\\}])";
with($0v){
prototype.fileFilter=new RegExp('.+\\\\(?!$|_)\\w*\\.js$','i');
prototype.$1n=["0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",9];
prototype.$1o={};
prototype.fso=Soya.Loader.fso||new ActiveXObject('Scripting.FilesystemObject');
prototype.core={};
prototype.bless={};
prototype.mangle={};
prototype.common={};
prototype.$1p=$g;
prototype.crunch=$0q;
prototype.flush=function(){this.buffer='';this.report=new $0c()};
prototype.getSubstitute=$0g;
prototype.loadMaps=$0d;
prototype.out=$0b;
prototype.load=$0e;
prototype.save=$0f;
prototype.getReport=$0r;
prototype.$1q=new RegExp("[$_]");
prototype.$1r=new RegExp("[^$\\w]","g");
prototype.$1s=new RegExp("^[\\x00\\.\"']");
prototype.$1t=new RegExp("\\s+$");
prototype.$1u=new RegExp("^\\s*\\W");
prototype.$1v=new RegExp("^[-\\\\+\"~'!]");
prototype.$1w=new RegExp("("+$0y+")|("+$0A+")","g");
prototype.$1x=new RegExp("("+$0B+")","g");
prototype.$1y=new RegExp("("+$0y+")|(\\r?\\n\\s+)|(\\x20{2,})","g");
prototype.$1z=new RegExp("("+$0y+")|(\\w+)?[ \\t]+("+$0z+")","g");
prototype.$1A=new RegExp("("+$0y+")|("+$0z+")[ \\t]+","g");
prototype.$1B=new RegExp("("+$0y+")|function[\\n\\s]+([$\\w]+)","g");
prototype.$1C=new RegExp("("+$0y+")|("+$0A+")|(\\W[\\n\\s]*?[$\\w]+)\\b","gm");
prototype.$1D=new RegExp("("+$0y+")|(\\x00)|\\.[\\n\\s]*?([$_][$\\w]{3,})","g");
prototype.$1E=new RegExp("("+$0y+")|("+$0C+")","g");
}
}
function $0b($0D,$0E){
if(!this.silent){
var $0F=String((!$0E?'ESC> ':'')+($0D||''));
WScript.Echo($0F);
}
}
function $0c(){
this.scripts=[];
this.rawSize=
this.crunchedSize=
this.elapsedTime=0;
}
function $0d(){
if(this.$1F)
return;
var $0G,$0H,$0I,$0J,$0K;
for(var i=0;i<arguments.length;i++){
$0G=arguments[i].replace(/\W.+$/,'');
try{
$0I=getResource(arguments[i]).split(/\r?\n/g)||[];
for(var j=0;j<$0I.length;j++)
if($0I[j].length&&!$0x.$1u.test($0I[j]))
Soya_Saltstorm_ESC.prototype[$0G][$0I[j].replace($0x.$1t,'')]=1;
if(this.verbose)
this.out('Parsed map "'+$0G+'", '+$0I.length+' entries.')
}
catch($0L){
if($0L)
$0I=null;
}
if($0I)
continue;
else $0H=this.fso.BuildPath(this.resourcePath,arguments[i]);
if(/^common|core/.test(arguments[i])&&!this.fso.FileExists($0H)){
this.out('Couldn\'t $0M $0N:'+
this.fso.GetAbsolutePathName($0H));
return WScript.Quit(99);
}
else if(typeof this[$0G]!='object'){
this.out('Unrecognized mapname : '+$0G);
return WScript.Quit(99);
}
else if(this.fso.FileExists($0H)){
$0I=this.fso.OpenTextFile($0H);
$0K=0;
while(!$0I.AtEndOfStream){
$0J=$0I.ReadLine();
if($0J.length&&!$0x.$1u.test($0J))
Soya_Saltstorm_ESC.prototype[$0G][$0J.replace($0x.$1t,'')]=++$0K;
}
$0I.Close();
Soya_Saltstorm_ESC.prototype[$0G].length=$0K;
if(this.verbose)
this.out('Loaded map "'+$0G+'", '+$0K+' entries. ['+$0H+']');
}
}
this.$1F=1;
}
function $0e(){
var i,$0O,$0P,$0Q,$0R=[];
for(i=0;i<arguments.length;i++){
if(arguments[i]&&this.fso.FolderExists(arguments[i])){
$0Q=new Enumerator(this.fso.GetFolder(arguments[i]).SubFolders);
for(;!$0Q.atEnd();$0Q.moveNext())
arguments[arguments.length++]=$0Q.item().Path;
$0Q=new Enumerator(this.fso.GetFolder(arguments[i]).Files);
for(;!$0Q.atEnd();$0Q.moveNext())
if($0Q.item().Size&&this.fileFilter.test($0Q.item().Path))
$0R.push($0Q.item().Path);
}
else if(arguments[i])
$0R.push(arguments[i]);
}
for(i=0;i<$0R.length;i++){
if(!this.fso.FileExists($0R[i])){
this.out('Couldn\'t $0M $0S:"' + this.fso.GetAbsolutePathName(aLoadQueue[i]) + '"');
return WScript.Quit(99);
}
else if(this.verbose)
this.out('Loading script :"'+this.fso.GetAbsolutePathName($0R[i])+'"');
$0P=this.fso.GetFile($0R[i]);
this.buffer+=(this.report.scripts.length?'\r\n':'');
this.buffer+=this.$1p($0P.Path,true);
this.report.scripts.push(
$0P.Path+' ('+($0P.Size/1024).toFixed(2)+' kb)');
}
return $0R.length;
}
function $0f($0T,$0U){
var $0V;
if(!$0T){
this.out('Need an output filename!');
return WScript.Quit(99);
}
else if(this.fso.FolderExists($0T)){
this.out('Need an output filename, "'+
this.fso.GetAbsolutePathName($0T)+'" is a folder.');
return WScript.Quit(99);
}
this.outFile=this.fso.GetAbsolutePathName($0T);
this.outMode=$0U?'Writing':'Appending';
$0V=this.fso.OpenTextFile(this.outFile,($0U?2:8),true);
$0V.WriteLine(this.buffer);
$0V.Close();
}
function $0g($0W){
if(!this.$1o[$0W]){
var k=1;
while(k<5){
this.$1n[k]++;
if(this.$1n[k]&&!(this.$1n[k]%62)){
k++;
if(this.$1n.length==k)
this.$1n[k]=-1;
}
else break;
}
this.$1o[$0W]='$';
for(k=this.$1n.length-1;k>0;k--)
this.$1o[$0W]+=this.$1n[0].charAt(this.$1n[k]%62);
if(this.verbose)
this.out('Substituting ['+this.$1o[$0W]+'] -> ['+$0W+']');
}
return this.$1o[$0W];
}
function $0h($0X,$0Y,$0Z){
if(typeof $0Z!='undefined')
return '';
else return $0X;
}
function $0i($0X,$10){
if(typeof $10!='undefined'&&/^\s+/.test($10))
return '\r\n';
else return $0X;
}
function $0j($0X,$11,$12){
if(typeof $11!='undefined')
return $0X;
else if($12&&$12.length>2&&
($0x.mangle[$12]||$0x.$1q.test($12.charAt(0))))
$12=$0x.getSubstitute($12);
else Soya_Saltstorm_ESC.prototype.bless[$12]=1;
return String('function \x00'+$12);
}
function $0k($0X,$11,$13,$14){
if(typeof $11=='undefined'&&typeof $13=='undefined'&&typeof $14=='string'){
$14=$14.replace(/\s+/g,'');
if(!$0x.$1s.test($14)&&isNaN(parseInt($14.substr(1),10))){
$14=$14.replace($0x.$1r,'');
if($14.length>2&&!$0x.core[$14]&&!$0x.common[$14]&&
!$0x.bless[$14]&&($0x.mangle[$14]||!$0x.mangle.length))
return $0X.replace($14,$0x.getSubstitute($14));
}
}
return $0X;
}
function $0l($0X,$11,$15,$P){
if(typeof $P=='string')
return(!$0x.core[$P]&&!$0x.common[$P]&&!$0x.bless[$P])?
String('.'+$0x.getSubstitute($P)):$0X;
else if(typeof $11!='undefined')
return $0X;
else return '';
}
function $0m($0X,$11,$16,$17,$18){
if(typeof $11!='undefined')
return $0X;
else if(typeof $16!='undefined')
return '\r\n';
else if(typeof $17!='undefined')
return ' ';
else return '';
}
function $0n($0X,$11,$19,$1a){
if(typeof $11=='undefined'){
if(!$0x.$1v.test($1a)||!$19||!$0x.core[$19])
return($19||'')+$1a;
else return $0X;
}
else return $11;
}
function $0o($0X,$11,$1a){
if(typeof $11!='undefined')
return $0X;
else return $1a;
}
function $0p($0X,$11,$1b,$1c){
if(typeof $11!='undefined')
return $0X;
return('};'+$1c);
}
function $0q($1d,$0s,$1e){
var $B=(typeof $1d=='string')?$1d:this.buffer;
this.loadMaps('core.map','common.map','bless.map','mangle.map');
if(!this.buffer.length&&!$1d)
return String();
else if(typeof $0s=='number')
this.crunchLevel=$0s;
var $1f=(new Date()).getTime()-1;
var $1g=$B.length;
this.report.rawSize+=$B.length;
if(this.crunchLevel>=1){
$B=$B.replace(this.$1w,$0h)
.replace(this.$1x,$0i)
.replace(/\s+\r?\n/g,'\r\n');
if(this.verbose)
this.out('Removing comments, empty lines and trailing whitespace, saved '+
($1g-$B.length)+' bytes.');
$1g=$B.length;
}
if(this.crunchLevel>=2){
$B=$B.replace(this.$1y,$0m);
if(this.verbose)
this.out('Removing tabs and spaces, saved '+
($1g-$B.length)+' bytes.');
$1g=$B.length;
$B=$B.replace(this.$1z,$0n);
if(this.verbose)
this.out('Removing spaces left to operators, saved '+
($1g-$B.length)+' bytes.');
$1g=$B.length;
$B=$B.replace(this.$1A,$0o);
if(this.verbose)
this.out('Removing spaces right to operators, saved '+
($1g-$B.length)+' bytes.');
$1g=$B.length;
}
if(this.substitute||$1e||this.crunchLevel>=4){
$B=$B.replace(this.$1B,$0j);
$B=$B.replace(this.$1C,$0k);
$B=$B.replace(this.$1D,$0l);
if(this.verbose)
this.out('Substitution summary, saved '+
($1g-$B.length)+' bytes.');
$1g=$B.length;
}
if(this.crunchLevel>=3){
$B=$B.replace(/\r?\n/g,'')
.replace(this.$1E,$0p);
$B+='\r\n';
if(this.verbose){
this.out('Removing newlines, saved '+
($1g-$B.length)+' bytes.');
this.out('',1);
}
}
if(typeof $1d=='string'){
this.report.crunchedSize+=$B.length;
this.buffer+=$B;
}
else{
this.buffer=$B;
this.report.crunchedSize=$B.length;
}
this.report.elapsedTime+=(new Date()).getTime()-$1f;
return this.buffer;
}
function $0r($1h){
var $1i=($1h||'\r\n'),
$1j=this.label?String($1i+this.label+$1i):'';
if(!this.report.elapsedTime){
$1j+='Nothing to report, yet...';
return(!$1k)?this.out($1j,1):$1j;
}
var $1l=Boolean(this.substitute||this.crunchLevel>=4),
$1m=this.report.rawSize-this.report.crunchedSize;
if(this.report.scripts.length){
$1j+="-----------------------------------------------------------------------------"+$1i;
$1j+=" Crunching script(s):\r\n\t * "+this.report.scripts.join("\r\n\t * ")+$1i;
$1j+="-----------------------------------------------------------------------------"+$1i;
$1j+=" "+(this.outMode||"Put")+" to : "+(this.outFile||"[buffer]")+" ("+
(this.report.crunchedSize/1024).toFixed(2)+" kb)"+$1i;
}
$1j+="-----------------------------------------------------------------------------"+$1i;
$1j+=" Processtime     :\t"+(this.report.elapsedTime/1000).toFixed(3)+" secs"+$1i;
$1j+=" Crunch-level    :\t"+this.crunchLevel+$1i;
$1j+=" Subst. engine   :\t"+($1l?'On':'Off')+$1i;
if($1l)
$1j+=" Substitutions   :\t"+(this.$1n[1]-9)+$1i;
$1j+=" Original size   :\t"+(this.report.rawSize/1024).toFixed(2)+" kb"+$1i;
$1j+=" Crunched size   :\t"+(this.report.crunchedSize/1024).toFixed(2)+" kb"+$1i;
$1j+=" Saving ratio    :\t"+($1m/1024).toFixed(2)+" kb"+$1i;
$1j+="   -'' ''-   (%) :\t"+(($1m/this.report.rawSize)*100).toFixed(2)+" %"+$1i;
$1j+="-----------------------------------------------------------------------------"+$1i;
return $1j;
}
if(typeof(Soya)=='object')Soya.registerBean('Soya.Saltstorm.ESC',false,1);

/*** </POD> ***/

]]>
</script>
<script language="JScript">
<![CDATA[
    /*
    Command flow control script for ESC.wsf
    Edited : 2005-02-06
    */

    var oShell = WScript.CreateObject('WScript.Shell');

    if(!oShell)
      WScript.Quit(64);

    // Do we have Jscript 5.5+ ?
    else if(oShell && parseFloat(ScriptEngineMajorVersion() + '.' + ScriptEngineMinorVersion()) < 5.5)
      oShell.Popup(getResource('jscript'), 64, WScript.ScriptName, 16), WScript.Quit(4);

    // Is ESC executed under cscript ?
    // if not let user select switching to cscript automagically.
    else if(oShell && WScript.FullName.toLowerCase().indexOf('cscript') < 0){
      if(oShell.Popup(getResource('wscript'), 64, WScript.ScriptName, 52) == 6)
        oShell.Run('%comspec% /Q /K cscript //NoLogo ' + WScript.ScriptName + ' -a', 9);
      WScript.Quit(3);
      }

    // get the cmdline arguments formatted in a nice manner.
    var oArgs = Soya.WSH.getArguments();

    // should we run in verbose-mode ?;
    var bVerbose = Boolean(!oArgs.s && !oArgs.silent && (oArgs.v || oArgs.verbose));

    // create an instance of the ESC object.
    var esc = new Soya.Saltstorm.ESC(oArgs.l || oArgs.level, bVerbose);
    esc.label = 'ESC (ECMAScript Cruncher) ' + esc.version +
             '\r\nCopyright (C) 2001-2005 Thomas Loo <tloo@saltstorm.net>';

    esc.resourcePath = esc.fso.GetParentFolderName(WScript.ScriptFullName || '.');
    var sOutput = String(oArgs.oa || oArgs.ow || '');

    if(oArgs.a || oArgs.about){
      WScript.Echo(getResource('about'));
      WScript.Quit(1);
      }
    else if(oArgs.c || oArgs.copyright){
      WScript.Echo('\n' + esc.label + getResource('copyright'));
      WScript.Quit(1);
      }
    else if(oArgs.e || oArgs.example){
      WScript.Echo('\n' + esc.label + getResource('example'));
      WScript.Quit(1);
      }

    // if there are options missing, print out the help table and quit.
    else if((oArgs.h || oArgs.help) || !sOutput.length || !oArgs[0]){
      WScript.Echo('\n' + esc.label + getResource('usage'));
      WScript.Quit((oArgs.h || oArgs.help) ? 1 : 2);
      }

    // Wake up the variable substitution engine if option set (-$);
    esc.substitute = Boolean(oArgs.$);

    // load input files;
    for(var i = 0; i < oArgs.length; i++)
      esc.load(oArgs[i]);

    // crunch baby, crunch!;
    if(sOutput.toUpperCase() == 'STDOUT'){
      esc.silent = true;
      WScript.StdOut.Write(esc.crunch());
      }
    else if(sOutput.length){
      esc.crunch();
      esc.save(sOutput, Boolean(oArgs.ow));
      // write report to stdout if not silence'd.
      if(!oArgs.s && !oArgs.silent)
        WScript.StdOut.Write(esc.getReport());
      }

    // Shutting down nicely..
    WScript.Quit(0);

]]>
</script>
</job>
</package>

加载全部内容

相关教程
猜你喜欢
用户评论