Advertisement
Golosomie

datmod vB

Dec 18th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. A GAME Mod by Hitler
  4.  
  5.   javascript:var s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='//pastebin.com/raw.php?i=HALDOL';void(0);
  6.  
  7. */
  8.  
  9. 'use strict';
  10. function Mod(){
  11.         jQuery.fn.outerHTML = function(s) { return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html(); };
  12.         // DISPLAY STUFF
  13.     document.getElementById("employment").style['margin-top'] = "0px";
  14.         document.getElementsByName("items_holder")[0].style['margin-bottom'] = "0px";
  15.         document.getElementById("lawmaker_upgrade_box").style.display = "none";
  16.     $('div[id="upgrades_container"]').hide();  //////--------- remove at prestiging
  17.         $('td[colspan="4"]').hide();
  18.     var css = document.createElement("style");
  19.     css.type = "text/css";
  20.     css.innerHTML = "span[name=attackedSpan] { pointer-events: none; }";
  21.     document.body.appendChild(css);
  22.     // VARS
  23.     this.mg = 5000*Math.pow(10,15);
  24.         this.moneyGoal = this.mg;
  25.         this.money = 0;
  26.         this.scMoney = 0;
  27.     this.oldROPM = 0;
  28.     this.eff = 1;
  29.     this.foo = 0;
  30.         this.workerID = 88;
  31.         this.j = 0;
  32.         this.c = 1000;
  33.     this.mGained = 0;
  34.     this.orePrice = [50,3,7,30,120,240,2250,3250,7000]
  35.         this.GBstate = 7; // 0 = GBwait 1 = GBopen 2=GBlobby 3 = 3=GBrunning
  36.         this.RBstate = 0;  // 2 = RBcd  1 = RBwait 0 = RBgo 3 = lolwas
  37.     this.activeCL = false;
  38.     this.getProds = false;
  39.         this.allsteves = false;
  40.         this.cWorker = true;
  41.         this.buystr = "";
  42.     this.wstr = "";
  43.         this.refreshstr = "";
  44.         this.raidTarget = "";
  45.         this.workstr = "";
  46.     this.buildstr = "";
  47.         this.pickMoney = 15590884;
  48.     // FETCHED INFO
  49.     this.oreTable = $('td[name="oresMined"]>span[class="ore"]');
  50.     this.chicks = $('tr[name="chickenfarmer"]').length;
  51.     this.w = (5 + this.chicks);
  52.     if($('span[id="pickaxe_var_name"]').text().indexOf('nti')){
  53.         this.prestige = (parseInt($('span[id="pickaxe_var_max"]').text())/30900)*20-20;
  54.     } else if($('span[id="pickaxe_var_name"]').text().indexOf('inal')){
  55.         this.prestige = (parseInt($('span[id="pickaxe_var_max"]').text())/20900)*20-20;
  56.     } else {
  57.         this.prestige = (parseInt($('span[id="pickaxe_var_max"]').text())/10900)*20-20;
  58.     }
  59.         this.limits= [1000,900,800,700,600];
  60.         this.price= [1500*(1+0.1*this.prestige),7500*(1+0.1*this.prestige),25000*(1+0.1*this.prestige),100000*(1+0.1*this.prestige),2500000*(1+0.1*this.prestige),7500000*(1+0.1*this.prestige)];
  61.     this.oreLimit = [[0,2],[3,8],[9,14],[15,21],[22,29],[30,38]];
  62.         this.prods= [106*(1+this.prestige/20),340*(1+this.prestige/20),1105*(1+this.prestige/20),8984*(1+this.prestige/20),23991*(1+this.prestige/20),35377*(1+this.prestige/20)];
  63.     if(this.chicks){
  64.         this.limits.push(600);
  65.         this.price.push(7500000000*(1+0.1*this.prestige));
  66.         this.oreLimit.push([39,47]);
  67.         this.prods.push(106389*(1+this.prestige/20));
  68.     }
  69.     this.oreLimit.push([39+9*this.chicks,47+9*this.chicks],[48+9*this.chicks,56+9*this.chicks]);
  70.     this.prods.push(35377*(1+this.prestige/20),38665*(1+this.prestige/20));
  71.     // TIMERS
  72.         this.timers = {
  73.                 update: false,
  74.                 lobby: 0,
  75.         };
  76.         // Updater
  77.         this.timers.update = setInterval(function(){ this.update(); }.bind(this), 100);
  78.         // Elements
  79.         this.elements = {
  80.                 aboutBox: $('<div style="float:left;width:250px"><h4><div style="display:inline-block;margin-left:3px;vertical-align:top;"></div><div id="mod"></div></h4></div>'),
  81.         };
  82.         $('<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js">').appendTo('body')
  83.         $('#gamecontainer').prepend(this.elements.aboutBox);
  84. }
  85.  
  86. Mod.prototype.checkProd = function(){
  87.     this.getProds = true;
  88.     this.oreTable = $('td[name="oresMined"]>span[class="ore"]');
  89.     this.update();
  90. }
  91. Mod.prototype.update = function(){
  92.         if("undefined" === typeof _) return;
  93.     if(this.getProds){
  94.         var tempTable = $('td[name="oresMined"]>span[class="ore"]');
  95.         if((tempTable[0].innerHTML!=this.oreTable[0].innerHTML)&&(tempTable[this.oreTable.length-1].innerHTML!=this.oreTable[this.oreTable.length-1].innerHTML)){
  96.             this.getProds = false;
  97.             this.calcProds(tempTable,this.oreTable);
  98.         }
  99.     }
  100.     //var C = parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''));
  101.     //var d = C-this.money;
  102.     //   if(d != 0){
  103.     //            this.money = C;
  104.     //            this.updateStats();
  105.     //          //console.log(new Date(+new Date+1000*this.frarf().t).toGMTString());
  106.     //    }
  107.     //    this.updateTitle();
  108. }
  109. Mod.prototype.o = function(){
  110.     var C = parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''));
  111.     console.log(C-this.j);
  112.     this.j = C;
  113. }
  114. Mod.prototype.calcProds = function(t2,t1){
  115.     var tempProds = [];
  116.     tempProds.length = this.oreLimit.length;
  117.     for(var i = 0; i<tempProds.length; i++){
  118.         var tempWorkerProd = 0;
  119.         for(var ore = this.oreLimit[i][1]; ore >= this.oreLimit[i][0]; ore--){
  120.             var oret2 = parseInt(t2[ore].innerHTML.slice(t2[ore].innerHTML.indexOf('x')+1,1337).replace(/,/g,""));
  121.             var oret1 = parseInt(t1[ore].innerHTML.slice(t1[ore].innerHTML.indexOf('x')+1,1337).replace(/,/g,""));
  122.             tempWorkerProd += this.orePrice[this.oreLimit[i][1]-ore]*(oret2-oret1);
  123.         }
  124.         tempProds[i] = tempWorkerProd/parseInt($('span[name="owned"]')[i].innerHTML.split(" ")[0]);
  125.     }
  126.     this.prods = tempProds;
  127. }
  128.  
  129. Mod.prototype.ev = function(L){
  130.     var ret = 0;
  131.     for(var i = 0; i < L.length; i++){
  132.         ret += (L[i] * this.prods[i])
  133.     }
  134.     return ret;
  135. }
  136. Mod.prototype.m = function(a){
  137.     if (a==8) {
  138.         this.moneyGoal = this.mg;
  139.     } else {
  140.         this.moneyGoal = this.price[a] * (Math.pow(1.025, parseInt($('span[name="owned"]')[a].innerHTML.split(" ")[0])))/this.hasCL();
  141.     }
  142. }
  143. Mod.prototype.hasCL = function(){
  144.         var re = 1;
  145.         for(var i = 0; i < $('span[name="item_details"]').length; i++){
  146.                 if($('span[name="item_details"]')[i].innerHTML.indexOf("Cheap Labor")>-1) {
  147.                         re = 2;
  148.                         break;
  149.                 }
  150.         }
  151.         return re;
  152. }
  153. Mod.prototype.z = function(){
  154.     return (parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''))/this.moneyGoal);
  155. }
  156. Mod.prototype.frarf = function(){
  157.     var C = parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''));
  158.     var E = parseInt($('td[name="wopmtimesresearch"]').text().replace(/,/g,""));
  159.     var scientistTime = parseInt($('span[name="scientistTime"]').text());
  160.     var scnts = parseInt($('span[name="scientists_owned"]').text());
  161.     var S = (1000*E/(scientistTime*scnts));
  162.     var r = Math.round(parseInt($('div[class="bar"]>span')[0].style['width'].replace(/%/g,""))*S/100);
  163.     S = Math.ceil(S);
  164.     if(r == S) {r -= 1; }
  165.     var W = [];
  166.     for(var i = 0; i < (8 + this.chicks); i++){
  167.         W.push(parseInt($('span[name="owned"]')[i].innerHTML));
  168.     }
  169.     return this.timeUntil(C,this.mg,E,r,S,W,this.w);
  170.     //console.log(this.reach(this.mg-C,E,r,S,this.ev(W)).t);
  171. }
  172. Mod.prototype.timeUntil = function(C,G,E,r,S,W,hW){
  173.     var ret = {m:0, t:0, w:[]};
  174.     if(G > C){
  175.         var x = this.reach(G-C,E,r,S,this.ev(W));
  176.         ret.t = x.t+1;
  177.         ret.m = x.m;
  178.         var iT = 0, iW, iP, ibW, y, iM, ibT = ret.t;
  179.         for(var i = hW; i>= 0; i--){
  180.             if(W[i]<this.limits[i]){
  181.                 iW = W.slice();
  182.                 iP = this.price[i] * Math.pow(1.025,iW[i]);
  183.                 iW[i] += 1;
  184.                 if(C >= iP){
  185.                     y = this.reach(iP+G-C,E,r,S,this.ev(iW));
  186.                     if(y.t < ibT){
  187.                         ibW = i;
  188.                         ibT = y.t;
  189.                         iM = iP;
  190.                     }
  191.                 } else {
  192.                     var z = this.timeUntil(C,iP,E,r,S,W,hW-1);
  193.                     y = this.reach(G+iP-(C+z.m),E + Math.floor((r+z.t)/S),(r+z.t)%S,S,this.ev(iW));
  194.                     if((z.t+y.t) < ibT){
  195.                         ibW = i;
  196.                         ibT = z.t+y.t;
  197.                         iT = z.t;
  198.                         iM = iP - z.m;
  199.                     }
  200.                 }
  201.             }
  202.         }
  203.         if(ibW != undefined){
  204.             var golo = W.slice();
  205.             golo[ibW] += 1;
  206.             ret = this.timeUntil(C-iM,G,E+Math.floor((r+iT)/S),(r+z.t)%S,S,golo,hW);
  207.             ret.t += iT;
  208.             ret.m -= iM;
  209.             ret.w.unshift(ibW);
  210.         }
  211.     }
  212.     return ret;
  213. }
  214. Mod.prototype.reach = function(M,E,r,S,B){
  215.     var ret = {t: 0, m: 0};
  216.     var t = 0;
  217.     var mg = 0;
  218.     r = S - r;
  219.     var PRi = r * (B+this.pickMoney) - 75000000;
  220.     B = B/(1+E/50);
  221.     if(PRi >= M){
  222.         ret.t = Math.Ceil(r * (M/PRi));
  223.         ret.m = PRi * (ret.t / r);
  224.     } else {
  225.         t = r;
  226.         mg = PRi;
  227.         var Y = (S * (E + 50.5) + (50 / B) * (S * this.pickMoney - 75000000));
  228.         var D = 100 * (M - mg) * (S/B);
  229.         var tq = Math.floor(Math.pow((Y*Y+D),0.5) - Y);
  230.         t += tq;
  231.         mg += tq*(tq+2*Y)*B/(100*S);
  232.         E += tq/S;
  233.         var tr = Math.ceil((M - mg) / ((1 + E/50)*B+this.pickMoney));
  234.         ret.m = mg + tr * ((1+E/50)*B+this.pickMoney);
  235.         ret.t = t + tr;
  236.     }
  237.     return ret;
  238. }
  239. Mod.prototype.updateStats = function(){
  240.         var efffact = 1; //(Math.pow(1.01,parseInt($('span[name="owned"]')[13].innerHTML))-1)*parseFloat($('span[id="village-happiness"]')[0].innerHTML)/100+1;
  241.         var fontstr = "";
  242.         var fontstr2 = "";
  243.         for(var i = 0; i < $('span[name="item_details"]').length; i++){
  244.                 if(($('span[name="item_details"]')[i].innerHTML.indexOf("Research Boost")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
  245.                         efffact *= 2;
  246.                         fontstr = "<font color='#00FF00'>";
  247.                         fontstr2 = "</font>";
  248.                 }else if(($('span[name="item_details"]')[i].innerHTML.indexOf("Diminishing Research")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
  249.                         efffact *= 2;
  250.                         fontstr = "<font color='#00FF00'>";
  251.                         fontstr2 = "</font>";
  252.                 }
  253.         }
  254.         var scnts = parseInt($('span[name="scientists_owned"]').text())*efffact;
  255.         var ropm = parseInt($('td[name="wopmtimesresearch"]').text().replace(/,/g,""));
  256.         if (ropm>this.oldROPM) {
  257.             this.oldROPM = ropm;
  258.             this.checkProd();
  259.         }
  260.         var scientistTime = parseInt($('span[name="scientistTime"]').text());
  261.         var bossCurrency = parseInt($('td[id="bc_display"]').text().replace(/,/g,""))/(3-this.hasCL());
  262.         var money = parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''));
  263.         this.eff = this.c*ropm/(scientistTime*scnts);
  264.         var buy = Math.ceil((Math.ceil(scnts*(this.eff/Math.floor(this.eff)-1)) - bossCurrency)/efffact);
  265.         var rtime = Math.floor((Math.floor(scientistTime * scnts * Math.ceil(this.eff) / this.c) - ropm) * Math.ceil(this.eff) / 60);
  266.         var sas = this.c/(Math.floor(this.eff)*Math.ceil(this.eff)*scientistTime*efffact);
  267.         var suus = (sas>=0.75) ? "NEVAR!" : Math.ceil(10*buy/(3600*(0.75-sas)))/10+"h";
  268.         if(parseInt($('span[name="owned"]')[9].innerHTML.replace(/,/g,""))<(Math.pow(10,8))){
  269.                 this.buystr = "/";
  270.         } else if(parseInt($('span[name="owned"]')[10].innerHTML.replace(/,/g,""))<(5*Math.pow(10,7))){
  271.                 this.buystr = "\\";
  272.         } else if((buy<-133.7)||(this.activeCL&&(bossCurrency>0))) {
  273.                 this.buystr = ">";
  274.                 document.getElementById("mod").innerHTML = "<br><br>" + fontstr + "eff: " + Math.round(100000*this.eff)/100000 + "s<br>" + fontstr2 + "<font color='#FF0000'>" + rtime + "min<br>KAUF MIT BC</font><br>"+Math.round(140*sas)+"% / d<br>"+this.wstr;
  275.         }else if((this.scMoney>0)&&(Math.ceil(2000*this.scMoney*(Math.pow(1.0005,88+(buy*efffact+bossCurrency)/efffact)-1)-money)<0)){
  276.                 this.buystr = "<";
  277.                 document.getElementById("mod").innerHTML = "<br><br>" + fontstr + "eff: " + Math.round(100000*this.eff)/100000 + "s<br>" + fontstr2 + "<font color='#FF0000'>" + rtime + "min<br>"+buy+" - "+ suus + "<br>"+Math.round(140*sas)+"% / d<br>KAUF MIT $$$</font><br>"+this.wstr;
  278.         }else{
  279.                 this.buystr = "";
  280.                 document.getElementById("mod").innerHTML = "<br><br>" + fontstr + "eff: " + Math.round(100000*this.eff)/100000 + "s<br>" + fontstr2 + rtime + "min<br>"+buy+" - "+suus+"<br>"+Math.round(140*sas)+"% / d<br>"+this.wstr;
  281.         }
  282. }
  283. Mod.prototype.updateTitle = function(){
  284.         //RB
  285.         if($('span[name="timer"][style="font-size: 19px; display: inline;"').length==1){
  286.                 this.RBstate = 2;
  287.         } else if((this.RBstate==2)&&($('div[id="popup"]:contains("SCENARIO")').length==1)) {
  288.                 this.RBstate = 3;
  289.         } else if(((this.RBstate==0)&&(($('div[id="popup"]:contains("SCENARIO")').length==1)||($('div[id="popup"]:visible:contains("already")').length==1)))||((document.getElementById("mining_container").style.display!=="none")&&($('body')[0].style["background-color"]=="rgb(15, 39, 41)"))) {
  290.                 this.RBstate = 1;
  291.         } else if((this.RBstate==2)||(($('div[id="popup"]:contains("SCENARIO")').length==0)&&(this.RBstate==3))) {
  292.                 this.RBstate = 0;
  293.         }
  294.         var RBstr = '';
  295.         if($('body')[0].style["background-color"]!=="rgb(15, 39, 41)"){
  296.                 RBstr = "PP";
  297.         }else if((document.getElementById("mining_container").style.display!=="none")&&($('body')[0].style["background-color"]=="rgb(15, 39, 41)")){
  298.                 RBstr = "R3";
  299.         }else if(this.RBstate==2){
  300.                 RBstr = "R2";
  301.         } else if(this.RBstate==1){
  302.                 RBstr = "R1";
  303.         } else if((this.RBstate==0)||(this.RBstate==3)){
  304.                 RBstr = "R0";
  305.         }
  306.         var popupHTML = $('div[id="popup"]')[0].innerHTML;
  307.         //GB
  308.         if($('img[name="globalBossImg"]:visible').length==1){
  309.                 this.GBstate = 3;
  310.         } else if ($('img[src="game/img/icons/globalBoss_big.png"]:visible').length==1){
  311.                 this.GBstate = 2;
  312.         } else if (($('span[name="timeRemaining"]').text()==("JOIN"||"LEAVE"))&&((this.GBstate==2)||(this.GBstate==0))){
  313.                 if(this.GBstate==0){this.timers.lobby = +new Date;}
  314.                 this.GBstate = 1;
  315.         } else if (($('span[name="timeRemaining"]').text().indexOf("min")>-1)||($('span[name="timeRemaining"]').text().indexOf("sec")>-1)){
  316.                 this.GBstate = 0;
  317.         } else if ((popupHTML.indexOf("You cannot join the event lobby")>-1)||((this.GBstate>0)&&(this.GBstate<5)&&((+new Date-this.timers.lobby)>61000))){
  318.                 this.GBstate = 6;
  319.         }
  320.         var GBstr = '';
  321.         if(this.GBstate==0){
  322.                 GBstr = 'G0';
  323.         }else if(this.GBstate==1){
  324.                 GBstr = 'G1';
  325.                 if((+new Date-this.timers.lobby)>50000){GBstr='G3';}
  326.         }else if(this.GBstate==2){
  327.                 GBstr = 'G2';
  328.                 if((+new Date-this.timers.lobby)>50000){GBstr='G4';}
  329.         }else if(this.GBstate==3){
  330.                 GBstr = 'G5';
  331.         }else if(this.GBstate==7){
  332.                 GBstr = 'G7';
  333.         }else if(this.GBstate==6){
  334.                 GBstr = 'G6';
  335.         }
  336.         //Inventory
  337.         var ItemString = '';
  338.     this.activeCL = false;
  339.         for(var i = 0; i < $('span[name="item_details"]').length; i++){
  340.                 var activated = ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1);
  341.                 if($('span[name="item_details"]')[i].innerHTML.indexOf("Ring of Efficiency")>-1) {
  342.                         ItemString += activated ? ':' : '.';
  343.                 }else if($('span[name="item_details"]')[i].innerHTML.indexOf("Cheap Labor")>-1) {
  344.             if(activated) {
  345.                 ItemString += 'I';
  346.                 this.activeCL = true;
  347.             } else {
  348.                 ItemString += 'i';
  349.             }
  350.                 }else if($('span[name="item_details"]')[i].innerHTML.indexOf("Double XP")>-1) {
  351.                         ItemString += activated ? '`' : '%';
  352.                 }else if($('span[name="item_details"]')[i].innerHTML.indexOf("Attack Boost")>-1) {
  353.                         ItemString += activated ? '`' : '&';
  354.                 }else if($('span[name="item_details"]')[i].innerHTML.indexOf("Godspear Fragment")>-1) {
  355.                         ItemString += activated ? ',' : '*';
  356.                 }else{
  357.                         ItemString += activated ? '`' : '!';
  358.                 }
  359.         }
  360.         //raiding
  361.         var raidstr = '';
  362.         /*if($('span[name="raidtime"]')[0].innerHTML==""){
  363.                 if(this.raidTarget==""){
  364.                         raidstr = "?";
  365.                 } else {
  366.                         raidstr = "_";
  367.                 }
  368.         }
  369.         */
  370.         //popup
  371.         var popupstr = '';
  372.         if($('div[id="popup"]:visible').length==1){
  373.                 if((popupHTML.indexOf("Raid report")>-1)||(popupHTML.indexOf("Chikolio")>-1)){
  374.                         popupstr = '~' + popupHTML.slice(popupHTML.indexOf("You"),popupHTML.indexOf("</div>")).trim();
  375.                 } else {
  376.                         popupstr = '^';
  377.                         if(popupHTML.indexOf("You are already fighting a boss.")>-1){
  378.                                 this.RBstate==1;
  379.                 RBstr=="R1";
  380.                         } else if((popupHTML.indexOf("What user do you want to raid")>-1)&&($('input[name="raid_user"]')[0].value!=this.raidTarget)&&(this.raidTarget!="")){
  381.                                 $('input[name="raid_user"]')[0].value = this.raidTarget;
  382.                         }
  383.                 }
  384.         }
  385.         //scMoney
  386.         var scstr = '';
  387.         if($('span[name="scientists_price"]')[0].innerHTML.indexOf("$")==0){
  388.                 scstr = '@';
  389.                 this.scMoney = parseInt($('span[name="scientists_price"]').text().replace(/,/g,'').replace('$',''));
  390.         } else if(this.scMoney==0){
  391.                 scstr = '=';
  392.         }
  393.         window.document.title = ItemString + "|" + this.refreshstr + this.workstr + scstr + this.buystr + GBstr + raidstr + RBstr + popupstr + '| A GAME';
  394. }
  395. Mod.prototype.terminate = function(){
  396.         _.each(this.elements, function(element){
  397.                 if(_.isArray(element)){
  398.                         _.each(element, function(el){ el.remove(); });
  399.                 }else{
  400.                         element.remove();
  401.                 }
  402.         });
  403.         clearInterval(this.timers.update);
  404.         window.m = undefined;
  405. }
  406. Mod.prototype.getKeks = function(name){
  407.     var parts = document.cookie.split(name + "=");
  408.     if(parts.length == 2){
  409.         return parts.pop().split(";").shift();
  410.     }
  411.     return false;
  412. }
  413. Mod.prototype.setKeks = function(Bezeichner,Wert){
  414.     var expire = (new Date(Math.pow(13,11))).toGMTString();
  415.     document.cookie=Bezeichner+"="+Wert+";expires="+expire+";";
  416. }
  417. // Start
  418. if(window.m) window.m.terminate();
  419. window.m = new Mod();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement