Friday, September 23, 2011

Beyond Business Tycoon Online


// ==UserScript==
// @name            Beyond Business Tycoon Online
// @namespace       beyondbto
// @description     Adds additional functionality to improve the Business Tycoon Online gaming experience.
// @exclude         http://*.bto.*.*/gamebto/ChatSocket.html*
// @exclude         http://*.bto.*.*/gamebto/kursaal.php
// @exclude         http://*.bto.*.*/gamebto/fate.php
// @exclude         http://*.bto.*.*/gamebto/ajax_action.php*
// @exclude         http://*.bto.*.*/gamebto/ajax_system.php*
// @exclude         http://*.bto.*.*/gamebto/task.php*
// @exclude         http://*.bto.*.*/gamebto/close.php*
// @exclude         http://*.bto.*.*/gamebto/ajax_toolsuse.php*
// @include         http://*.bto.*.*/gamebto/*
// @exclude         http://s*.daigia.sgame.vn/gamebto/ChatSocket.html*
// @exclude         http://s*.daigia.sgame.vn/gamebto/kursaal.php
// @exclude         http://s*.daigia.sgame.vn/gamebto/fate.php
// @exclude         http://s*.daigia.sgame.vn/gamebto/ajax_action.php*
// @exclude         http://s*.daigia.sgame.vn/gamebto/ajax_system.php*
// @exclude         http://s*.daigia.sgame.vn/gamebto/task.php*
// @exclude         http://s*.daigia.sgame.vn/gamebto/close.php*
// @exclude         http://s*.daigia.sgame.vn/gamebto/ajax_toolsuse.php*
// @include         http://s*.daigia.sgame.vn/gamebto/*
// @exclude         http://kgbto.dovogame.com/*/gamebto/ChatSocket.html*
// @exclude         http://kgbto.dovogame.com/*/gamebto/kursaal.php
// @exclude         http://kgbto.dovogame.com/*/gamebto/fate.php
// @exclude         http://kgbto.dovogame.com/*/gamebto/ajax_action.php*
// @exclude         http://kgbto.dovogame.com/*/gamebto/ajax_system.php*
// @exclude         http://kgbto.dovogame.com/*/gamebto/task.php*
// @exclude         http://kgbto.dovogame.com/*/gamebto/close.php*
// @exclude         http://kgbto.dovogame.com/*/gamebto/ajax_toolsuse.php*
// @include         http://kgbto.dovogame.com/*/gamebto/*
// @exclude         http://kgbto.dovogame.com/index.php*
// @exclude         http://www.kongregate.com/games/BusinessTycoon/business-tycoon-online/
// @include         http://beyondbto.villagesatwar.com/*
// @exclude         http://*.beyondbto.com/wp-admin/*
// @include         http://*.beyondbto.com/*


// ==/UserScript==


window.addEventListener('load', function(){
 function getCookie(name){var cookies = document.cookie;if (cookies.indexOf(name) != -1){var startpos = cookies.indexOf(name)+name.length+1;var endpos = cookies.indexOf(";",startpos)-1;if (endpos == -2) endpos = cookies.length;return unescape(cookies.substring(startpos,endpos));}else{return null;}}
 function setCookie(name, value, expires){if (!expires) expires = new Date()+ (1000 * 60 * 60 * 24 * (365*10)); document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";}
 function getBbtoid(){var BBTO_id = GM_getValue("BBTO.ID");if (BBTO_id==undefined || BBTO_id==null) BBTO_id = localStorage.getItem("BBTO.ID");if (BBTO_id==undefined || BBTO_id==null) BBTO_id = getCookie("BBTO.ID");if (BBTO_id==undefined || BBTO_id==null) BBTO_id = "";return "&tid="+BBTO_id;}
 function setBbtoid(i){setTimeout(function(){GM_setValue("BBTO.ID",i)},0);localStorage.setItem("BBTO.ID",i);setCookie("BBTO.ID",i);}

 
 var bbtocode = "";
 
 //http://s9.bto.dovogame.com/gamebto/
 if (unsafeWindow.location.href.indexOf('beyondbto.villagesatwar.com')>0) {
  
 } else if (unsafeWindow.location.href.indexOf('beyondbto.com')>0) {
  unsafeWindow.execGreaseMonkey({version:'1.0'});
 
 } else if (unsafeWindow.location.href.indexOf('www.kongregate.com')>0) {
  var WRAP_Name="KONG";
  
  /*Support for other sites that want to 'wrap' BTO in their own interfaces */
  
  var WRAP_version = GM_getValue(WRAP_Name+".Version");
  if (WRAP_version==undefined) WRAP_version=0;
  
  var WRAP_url = "http://beyondbto.villagesatwar.com/bbto.php?wrapper="+WRAP_Name+"&"+bbtocode+"version="+WRAP_version;
  GM_xmlhttpRequest({
   method: 'GET', url: WRAP_url, onload: function(r) {
    var aR = r.responseText.split("|");
    if (aR[0]==WRAP_version+'DEV') {
     var WRAP_code = GM_getValue(WRAP_Name+".Code");
     try {
      var myFucn = new Function(WRAP_code);
      eval('setTimeout(myFucn, 0)');
      return;
     } catch(err) {
      //Grab current server version
     }
    }
    WRAP_version=aR[0];
    GM_log('WRAP.'+WRAP_Name+"."+WRAP_version+' :: Fetching Code '+WRAP_version);
    var WRAP_url = "http://beyondbto.villagesatwar.com/bbto.php?wrapper="+WRAP_Name+"&"+bbtocode+"code="+BBTO_version;
    GM_xmlhttpRequest({
     method: 'GET', url: WRAP_url, onload: function(r) {
      var WRAP_code = r.responseText;
      try {
       var myFucn = new Function("WRAP_Name='"+WRAP_Name+"';\n" + WRAP_code);
       eval('setTimeout(myFucn, 0)');
       setTimeout(function(){
        GM_setValue(WRAP_Name+".Version",WRAP_version);
        GM_setValue(WRAP_Name+".Code",WRAP_code);
       },0);
       setTimeout(function() {
        //unsafeWindow.jQuery("#bbtoV").html(WRAP_version+" (new)");
       },1000);

      } catch(err) {
       var WRAP_code = GM_getValue(WRAP_Name+".Code");
       if (WRAP_code!=undefined) {
        var myFucn = new Function(WRAP_code);
        eval('setTimeout(myFucn, 0)');
       }
       setTimeout(function() {
        //unsafeWindow.jQuery("#bbtoV").html(BBTO_version+" (error)");
       },1000);
      }
      
     }
    });
    return;
   }
  });
  
 } else if (unsafeWindow.a==undefined) {
  //On Landing page or Login Page
 } else {
  var BBTO_version = GM_getValue("BBTO.Version");
  if (BBTO_version==undefined) BBTO_version=0;
  
  for each(var val in GM_listValues()) {
   if (localStorage.getItem(val)==undefined || localStorage.getItem(val)==null) {
    if (val=='BBTO.Code' || val=='BBTO.Version' || val=='BBTO.ID') {
     //Do not save local
    } else {
     localStorage.setItem(val, GM_getValue(val));
    }
   }
  }

  var BBTO_accountinfo="";
  /* PRIVACY : START
   Remove the // from the line below to not submit any Business Tycoon Online account information.
   Each parameter being sent is documented so that you can individually comment them out.
  */
  
  /* APPRECIATED VARIABLES */
  BBTO_accountinfo+="&sid="+unsafeWindow.a.ServerId; /* Server Id - server number */
  BBTO_accountinfo+="&sn="+unsafeWindow.a.ServerName; /* ServerName */
  BBTO_accountinfo+="&pid="+unsafeWindow.a.UserId; /* User Id - Payer number - while never shown, it is passed in the code all the time */
  BBTO_accountinfo+="&pn="+unsafeWindow.a.VUserName; /* Player Name */
  BBTO_accountinfo+="&aid="+unsafeWindow.a.UNUserId; /* Guild Id - Guild Id - not Guild Name, would of made life simplier if they had just included that too */
  BBTO_accountinfo+="&pf="+unsafeWindow.a.user_pic; /* Player Face - might use this to create personel Beyond BTO Relationship Information Manager */
  BBTO_accountinfo+="&it="+unsafeWindow.a.IndustryId; /* Industry Type (Service, Sales, etc. */
  
  /* NOT REQUIRED VARIABLES */
  BBTO_accountinfo+="&pa="+unsafeWindow.a.user_regdays; /* The number of days the player has been playing. This is for statistical analysis - not required */
  BBTO_accountinfo+="&e="+unsafeWindow.a.user_Employees+"."+unsafeWindow.a.MaxEmployees; /* Current and Maximum Employees */
  BBTO_accountinfo+="&s="+unsafeWindow.a.user_OwnerShops+"."+unsafeWindow.a.MaxShopNums; /* Current and Maximum Employees */
  BBTO_accountinfo+="&d="+unsafeWindow.a.user_diamond; /* Diamonds user has bought */
  BBTO_accountinfo+="&m="+unsafeWindow.a.user_yesterdayearning; /* Yesterday's earning */
  
  //BBTO_accountinfo = ""; /* <---- This is the line to remove the // from. It will blank the account info */
  
  /* PRIVACY : END */
  var BBTO_url = "http://beyondbto.villagesatwar.com/bbto.php?"+bbtocode+"version="+BBTO_version+getBbtoid()+BBTO_accountinfo;
  GM_xmlhttpRequest({
   method: 'GET', url: BBTO_url, onload: function(r) {
    var aR = r.responseText.split("|");
    if (aR[0]==BBTO_version+'DEV') {
     var BBTO_code = GM_getValue("BBTO.Code");
     try {
      var myFucn = new Function(BBTO_code);
    
      eval('setTimeout(myFucn, 0)');
      setTimeout(function() {
       unsafeWindow.jQuery("#bbtoV").html(BBTO_version+"");
       
       var BBTO_news = GM_getValue("BBTO.News");
       if (BBTO_news==undefined) {
        /* Grab latest news - only send version number - no account information */
        var BBTO_url = "http://beyondbto.villagesatwar.com/bbto.php?news="+BBTO_version+"";
        GM_xmlhttpRequest({method: 'GET', url: BBTO_url, onload: function(r) {
         unsafeWindow.BBTO_news = unsafeWindow.jQuery.parseJSON(r.responseText);
         setTimeout(function(){
          GM_setValue("BBTO.News",r.responseText);
         },0);
        }});
       } else {
        unsafeWindow.BBTO_news = unsafeWindow.jQuery.parseJSON(BBTO_news);
       }
       
      },1000);
      
      return;
     } catch(err) {
      //Grab current server version
     }
    }
    BBTO_version=aR[0];
    GM_log('BBTO.'+BBTO_version+' :: Fetching Code '+BBTO_version);
    var BBTO_url = "http://beyondbto.villagesatwar.com/bbto.php?"+bbtocode+"code="+BBTO_version+getBbtoid()+BBTO_accountinfo;
    GM_xmlhttpRequest({
     method: 'GET', url: BBTO_url, onload: function(r) {
      var BBTO_code = r.responseText;
      try {
       
       var myFucn = new Function(BBTO_code);
       eval('setTimeout(myFucn, 0)');
       setTimeout(function(){
        GM_setValue("BBTO.Version",BBTO_version);
        GM_setValue("BBTO.Code",BBTO_code);
       },0);
       setTimeout(function() {
        unsafeWindow.jQuery("#bbtoV").html(BBTO_version+" (new)");
       },1000);
       
       /* Grab latest news - only send version number - no account information */
       var BBTO_url = "http://beyondbto.villagesatwar.com/bbto.php?news="+BBTO_version+"";
       GM_xmlhttpRequest({method: 'GET', url: BBTO_url, onload: function(r) {
        unsafeWindow.BBTO_news = unsafeWindow.jQuery.parseJSON(r.responseText);
        setTimeout(function(){
         GM_setValue("BBTO.News",r.responseText);
        },0);
       }});
       
      } catch(err) {
       var BBTO_code = GM_getValue("BBTO.Code");
       if (BBTO_code!=undefined) {
        var myFucn = new Function(BBTO_code);
        eval('setTimeout(myFucn, 0)');
       }
       setTimeout(function() {
        unsafeWindow.jQuery("#bbtoV").html(BBTO_version+" (error)");
       },1000);
      }
      
     }
    });
    return;
   }
  });
 }
}, false);

0 comments:

Post a Comment