/* '* Project: 51奴隶庄园刷分 '* FileName: IScript.js '* Authors: Perry */ var $GLOBAL = this; var $PPSOFT = {}; var app = null; var Class = { Create: function ( name, ns, i, e, r ){ var $_ = typeof ns == "string" ? Class.Namespace( ns ) : typeof ns == "object" ? ns : $PPSOFT; if ( typeof $_[name] != "function" ){ $_[name] = function (){ this.strClassName = ( typeof ns == "string" ? ns : ns.strClassName ) + "." + name; this.toString = function(){ return this.strClassName; }; if ( typeof this.initialize == "function" ){ this.initialize.apply( this, arguments ); } }; } if ( i != null ){ Class.Extend ( $_[name].prototype, typeof i == "function" ? i.prototype : i, true ); } if ( e != null ){ Class.Extend ( $_[name].prototype, e, r ); } return $_[name]; }, Extend: function ( dst, src, r ){ for ( var $$ in src ){ if ( !r && dst[$$] != null ){ continue; } try { dst[$$] = src[$$]; }catch(e){} } return dst; }, Namespace: function ( ns ){ if ( typeof ns != "string" ){ return null; } var nslvl = ns.split( "." ); var $$ = $GLOBAL; for ( var i = 0; i < nslvl.length; i++ ){ $$[nslvl[i]] = $$[nslvl[i]] || {}; $$ = $$[nslvl[i]]; } return $$; } }; Class.Extend ( Function.prototype, { apply: function( o, args ){ var $0, $1, $2 = "___call"; if ( typeof o != "object" ){ o = {}; } o[$2] = this; $1 = "$0 = o." + $2 + "("; for ( var i = 0; i < args.length; i++ ){ if ( i > 0 ){ $1 += ","; } $1 += "args[" + i + "]"; } $1 += ");"; eval ( $1 ); delete o[$2]; } }, true ); Class.Extend ( Number.prototype, { fixed: function( f, len ){ var s = ""; for ( var i = 0; i < len; i++ ){ s+=f; } s += this; return s.substr ( s.length - len ); } }, true ); Class.Extend ( Date.prototype, { format: function( format ){ var weeks = [ "日", "一", "二", "三", "四", "五", "六" ]; return format .replace ( /yyyy/g, this.getFullYear ().fixed ( "0", 4 ) ) .replace ( /MM/g, (this.getMonth ()+1).fixed ( "0", 2 ) ) .replace ( /dd/g, this.getDate ().fixed ( "0", 2 ) ) .replace ( /hh/g, this.getHours ().fixed ( "0", 2 ) ) .replace ( /mm/g, this.getMinutes ().fixed ( "0", 2 ) ) .replace ( /ss/g, this.getSeconds ().fixed ( "0", 2 ) ) .replace ( /iii/g, this.getMilliseconds ().fixed ( "0", 3 ) ) .replace ( /www/g, "星期" + weeks[this.getDay ()] ); }, Span: function ( date ){ var dd = Math.abs ( this - date ); var txt = ""; var _list = [ { Name: '毫秒', Unit: 1000, Value: 0 }, { Name: '秒', Unit: 60, Value: 0 }, { Name: '分钟', Unit: 60, Value: 0 }, { Name: '小时', Unit: 24, Value: 0 }, { Name: '天', Unit: 10000,Value: 0 } ]; for ( var i = 0; i < _list.length; i++ ){ _list[i].Value = dd % _list[i].Unit; dd -= _list[i].Value; dd /= _list[i].Unit; } while ( --i ){ txt += _list[i].Value.fixed ( "0", 2 ) + _list[i].Name; } return txt ; } }, true ); Class.Extend ( $PPSOFT, { $a: function ( c ){ try { return new ActiveXObject ( c ); } catch ( Exception ){} return null; }, $d: function ( e ){ var $_ = e.parentElement || e.parentNode; if ( $_ != null ) { $_.removeChild ( e ); } }, $f: function ( id ){ var $_ = this.$w ( 1 ).getElementById( id ); if ( $_ != null ){ return $_; } $_ = this.$w ( 1 ).all[ id ]; if ( $_ != null ){ return ele; } return null; }, $c: function ( tagName, key, parent, attrs, styles ){ var $_ = this.$f ( key ); if ( $_ ) { return null; } $_ = this.$w ( 1 ).createElement ( tagName ); if ( typeof key == "string" ) { $_.setAttribute ( "id", key ); } if ( typeof attrs == "object" ) { Extend ( $_, attrs, true ); } if ( typeof styles == "object" ){ this.$s ( $_, styles ); } if ( typeof parent == "object" ){ this.$i ( parent, $_ ); } return $_; }, $i: function ( parent, child ){ if ( parent && child ){ if ( child.parentElement != parent ){ parent.appendChild ( child ); } } return child; }, $s: function ( o, s, v ){ if ( o && o.style ){ if ( typeof s == "string" && o.style[s] != undefined ){ o.style[s] = v; } if ( typeof s == "object" ){ Extend ( o.style, s, true ); } } return o; }, $w: function ( n ){ return [this,document,document.body][n]; }, $k: function ( p ){ var key; do { key = p + Math.random().toString().match(/[0-9]{5,}/); } while ( this.$f ( key ) ) return key; } }, true ); Class.Create ( "TObject", $PPSOFT, null, { }, true ); Class.Create ( "Application", $PPSOFT, $PPSOFT.TObject, { Run: function () { } }, true ); Class.Create ( "HttpClient", $PPSOFT, $PPSOFT.TObject, { Resource: "", Status: false, HttpObject: null, HttpHeaders: [], initialize: function ( res ){ this.HttpObject = $PPSOFT.$a ( "Msxml2.xmlhttp" ); if ( typeof res == "string" ){ this.Resource = res; } }, AddHeaders: function ( name, value ){ for ( var i = 0; i < this.HttpHeaders.length; i++ ){ if ( this.HttpHeaders[i].name.toLowerCase () == name.toLowerCase () ){ this.HttpHeaders[i].value = value; return this; } } this.HttpHeaders.push ( { name: name, value: value } ); return this; }, Request: function ( post, param, data, callback ){ var $$ = this; var $res = ""; var $url = $$.Resource; try { if ( $$.Status || post ){ if ( $$.HttpObject.readyState != 0 ){ $$.HttpObject.abort(); } } $$.HttpObject.onreadystatechange = function (){ if ( $$.HttpObject.readyState == 4 ){ $$.Status = false; if ( $$.HttpObject.status == 200 ){ $res = $$.HttpObject.responseText; } $$.OnResponse ( $res ); if ( typeof callback == "function" ){ callback ( $res ); } } }; if ( typeof param == "string" && param.length > 0 ){ $url += ( $url.search ( //?/g ) > 0 ? "&" : "?" ) + param; } $$.HttpObject.Open ( post ? "POST":"GET", $url, true ); for ( var i = 0; i < $$.HttpHeaders.length; i++ ){ $$.HttpObject.setRequestHeader ( $$.HttpHeaders[i].name, $$.HttpHeaders[i].value ); } if ( post ){ $$.HttpObject.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded" ); } $$.HttpObject.Send ( data ); $$.Status = true; } catch ( exception ){ alert(exception.message); } return $$; }, OnResponse: function ( res ){} }, true ); Class.Create ( "RebuildMe", $PPSOFT, $PPSOFT.TObject, { WinObject: null, ScriptURL: "", Count: 0, Reset: function (){ var $$ = this; if ( $$.ScriptURL == "" ){ try { $$.ScriptURL = eval ( "$script" ); } catch ( e ) {} } if ( $$.ScriptURL.indexOf ( "file:///" ) == -1 ){ return; } $$.WinObject = open( "/helot/shop_crazy_broadcast.php", "", "toolbar=no,statusbar=no,left=" + (screenLeft - 3) + ",top=" + (screenTop - 22) + ",height=100,width=350" ); setTimeout ( function (){ $$.WaitOfComObject ( "$$.WinObject.document.body", function (){ $$.WinObject.$script = $$.ScriptURL; $$.WinObject.document.body.appendChild ( $$.WinObject.document.createElement ( "SCRIPT" ) ).src = $$.ScriptURL; $$.WinObject.document.body.style.cssText = "border: none;padding:10px;font-size:12px;"; $$.WaitOfComObject ( "$$.WinObject.RebuildMe", function (){ $$.WinObject.RebuildMe.ScriptURL = $$.ScriptURL; $$.WinObject.RebuildMe.Count++; opener = null; open ( "", "_self", "" ); close (); } ); } ); }, 4500 ); }, WaitOfComObject:function ( ObjectName, Callback ){ var $$ = this; try { if ( eval ( ObjectName ) ){ Callback (); return; } throw ""; } catch ( e ) { setTimeout ( function (){ $$.WaitOfComObject ( ObjectName, Callback ); }, 500 ); } } }, true ); Class.Create ( "Game", $PPSOFT, $PPSOFT.TObject, { HttpClient: null, GameType: 54, IsContinual: false, ContinueCount:0, WinAward: 10000, WinCount: 0, LoseCount: 0, PacficCount: 0, PlayCount: 0, StartTime: null, initialize: function (){ var $$ = this; $$.HttpClient = new $PPSOFT.HttpClient ( "http://yy.51.com/helot/recreation_pop_adv.php" ); $$.HttpClient .AddHeaders ( "Host", "yy.51.com" ) .AddHeaders ( "x-flash-version","10,0,12,36" ) .AddHeaders ( "Referer", "http://pic.51.com/app/helot_new/swf/sezi.swf" ) .OnResponse = function ( res ){ var $1 = parseInt( res.match ( /[0-9]{3,5}/ ) ); $$.PlayCount++; if ( !isNaN ( $1 ) ){ if ( $1 == 500 ){ $$.LoseCount++; } if ( $1 == $$.WinAward ){ $$.WinCount++; } } else { $$.PacficCount++; } $$.OnPlayResult ( { Cost: $1, WinAward: $$.WinAward, WinCount: $$.WinCount, LoseCount: $$.LoseCount, PlayCount: $$.PlayCount, PacficCount:$$.PacficCount, AcquireCash:$$.WinCount * $$.WinAward - $$.LoseCount * 500, ConsumeTime:$$.StartTime.Span ( new Date ) } ); }; }, SetGameType: function ( nType ){ this.GameType = nType; }, Play: function ( interval ){ var $$ = this; if ( $$.ContinueCount == 0 && interval > 0 ){ $$.IsContinual = true; $$.StartTime = new Date; } $$.HttpClient.Request ( true, null, "type=" + $$.GameType + "&run=2", function ( res ){ if ( !$$.IsContinual ){ return; } setTimeout ( function (){ $$.ContinueCount++; $$.Play ( interval ); }, interval ); } ); }, Stop: function (){ if ( this.ContinueCount > 0 ){ this.IsContinual = false; this.ContinueCount= 0; } }, OnPlayResult: function ( o ){} }, true ); Class.Create ( "Purse", $PPSOFT, $PPSOFT.TObject, { HttpClient: null, initialize: function (){ var $$ = this; $$.HttpClient = new $PPSOFT.HttpClient ( "/helot/recreation.php?sec_menu=2" ); $$.HttpClient .AddHeaders ( "Host", "yy.51.com" ) .OnResponse = function ( res ){ var $1 = parseInt( res.match ( /(<font color=/"/#FF0000/">)+([0-9]{1,})+(<//font>)/ )[2] ); if ( isNaN ( $1 ) ){ $1 = 0; } $$.OnPlayResult ( $1 ); }; }, GetNow: function ( callback ){ var tClient = new $PPSOFT.HttpClient ( "/helot/recreation.php?sec_menu=2" ); tClient.Request ( false, null, null, function ( res ){ if ( typeof callback == "function" ){ callback ( parseInt( res.match ( /(<font color=/"/#FF0000/">)+([0-9]{1,})+(<//font>)/ )[2] ) ); } } ); }, Play: function ( interval ){ var $Q = this; $Q.HttpClient.Request ( false, null, null, function ( res ){ } ); setTimeout ( function (){ $Q.Play ( interval ); }, interval ); }, OnPlayResult: function ( o ){} }, true ); Class.Create ( "WebPage", $PPSOFT, $PPSOFT.TObject, { objFrame: null, Labels: [], initialize: function (){ this.Clear (); for ( var i = 0; i < 7; i++ ){ this.Labels.push ( document.createElement("DIV") ); with ( document.body.appendChild ( this.Labels[i] ) ){ style.fontSize = "24px"; style.width = "100%"; style.textAlign = "left"; style.textIndent= "15px"; } } this.Labels[0].innerText = document.cookie.match(/(_user=)([0-9a-zA-Z_]{4,})(;)/)[2]; }, Clear: function (){ document.body.innerHTML = ""; }, SetLabelText: function ( id, value, color ){ this.Labels[id].innerText = value; if ( typeof color == "string" && color.indexOf ("#") > -1 ){ this.Labels[id].style.color = color; } }, Show: function (){ } }, true ); if(typeof WScript == "object"){ Class.Extend ( $PPSOFT.Application.prototype, { LocalPath: "", InjectCode: "", ShellObject: null, initialize: function (){ this.LocalPath = encodeURI("file:///" + WScript.scriptFullName.replace(////g,"//")); this.InjectCode = "javascript:var $script=/"" + this.LocalPath + "/";document.body.appendChild(document.createElement(/"script/")).src=$script;void(0);"; this.ShellObject= $PPSOFT.$a ( "WScript.Shell" ); }, Run: function (){ this.ShellObject.Run("notepad") WScript.Sleep ( 150 ); for ( var i=0; i < this.InjectCode.length; i++ ){ this.ShellObject.SendKeys("{" + this.InjectCode.charAt(i) + "}"); } WScript.Sleep(20); this.ShellObject.SendKeys("^a"); WScript.Sleep(20); this.ShellObject.SendKeys("^c"); WScript.Sleep(20); this.ShellObject.SendKeys("%{F4}"); WScript.Sleep(20); this.ShellObject.SendKeys("{n}"); } }, true ); }else{ Class.Extend ( $PPSOFT.Application.prototype, { WebPage: null, Game: null, Purse: null, initialize: function (){ var $$ = this; $$.WebPage = new $PPSOFT.WebPage; $$.Purse = new $PPSOFT.Purse; $$.Game = new $PPSOFT.Game; $$.Purse.GetNow ( function ( p ){ $$.WebPage.SetLabelText ( 5, "开始前资金:" + p ); $$.WebPage.SetLabelText ( 6, "现在的资金:" + p ); } ); $$.Purse.OnPlayResult = function ( p ){ $$.WebPage.SetLabelText ( 6, "现在的资金:" + p ); }; $$.Game.OnPlayResult = function ( o ){ $$.WebPage.SetLabelText ( 1, "其中我赢了:" + o.WinCount + "局" ); $$.WebPage.SetLabelText ( 2, "其中我输了:" + o.LoseCount + "局" ); $$.WebPage.SetLabelText ( 3, "目前总收入:" + o.AcquireCash, o.AcquireCash < 0 ? "#ff0000":"#0000ff" ); $$.WebPage.SetLabelText ( 4, "使用了时间:" + o.ConsumeTime ); }; }, Run: function (){ this.WebPage.Show (); this.Game.Play ( 50 ); this.Purse.Play ( 15000 ); } }, true ); setTimeout ( 'document.ondblclick.Default()', 20 * 60000 ); } app = new $PPSOFT.Application; app.Run ();