Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- A GAME Mod by Hitler
- javascript:var s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='//pastebin.com/raw.php?i=HALDOL';void(0);
- */
- 'use strict';
- function Mod(){
- jQuery.fn.outerHTML = function(s) { return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html(); };
- // DISPLAY STUFF
- document.getElementById("employment").style['margin-top'] = "0px";
- document.getElementsByName("items_holder")[0].style['margin-bottom'] = "0px";
- //document.getElementById("lawmaker_upgrade_box").style.display = "none";
- $('div[id="upgrades_container"]').hide(); //////--------- remove at prestiging
- $('td[colspan="4"]').hide();
- var css = document.createElement("style");
- css.type = "text/css";
- css.innerHTML = "span[name=attackedSpan] { pointer-events: none; }";
- document.body.appendChild(css);
- // VARS
- this.mg = 50000000000000*Math.pow(10,game.prestige);
- this.moneyGoal = this.mg;
- this.oldROPM = 0;
- this.oldMoney = 0;
- this.eff = 1;
- this.buyBCscnts = false;
- this.orePrice = [50,3,7,30,120,240,2250,3250,7000]
- this.GBstate = 7; // 0 = GBwait 1 = GBopen 2=GBlobby 3 = 3=GBrunning
- this.RBstate = 0; // 2 = RBcd 1 = RBwait 0 = RBgo 3 = lolwas
- this.getProds = false;
- this.buystr = "";
- this.wstr = "";
- this.ItemString = "";
- this.refreshstr = "";
- this.raidTarget = "";
- this.workstr = "";
- this.buildstr = "";
- this.pickMoney = 15590884;
- this.mapActive = (game.adventure.stage > 0);
- // FETCHED INFO
- this.oreTable = $('td[name="oresMined"]>span[class="ore"]');
- this.chicks = $('tr[name="chickenfarmer"]').length;
- this.w = (5 + this.chicks);
- this.limits= [1000,900,800,700,600];
- this.price= [1500*(1+0.1*game.prestige),7500*(1+0.1*game.prestige),25000*(1+0.1*game.prestige),100000*(1+0.1*game.prestige),2500000*(1+0.1*game.prestige),7500000*(1+0.1*game.prestige)];
- this.oreLimit = [[0,2],[3,8],[9,14],[15,21],[22,29],[30,38]];
- this.prods= [106*(1+game.prestige/20),340*(1+game.prestige/20),1105*(1+game.prestige/20),8984*(1+game.prestige/20),23991*(1+game.prestige/20),35377*(1+game.prestige/20)];
- if(this.chicks){
- this.limits.push(600);
- this.price.push(7500000000*(1+0.1*game.prestige));
- this.oreLimit.push([39,47]);
- this.prods.push(106389*(1+game.prestige/20));
- }
- this.oreLimit.push([39+9*this.chicks,47+9*this.chicks],[48+9*this.chicks,56+9*this.chicks]);
- this.prods.push(35377*(1+game.prestige/20),38665*(1+game.prestige/20));
- // TIMERS
- this.timers = {
- update: false,
- lobby: 0,
- };
- // Updater
- this.timers.update = setInterval(function(){ this.update(); }.bind(this), 100);
- // Elements
- this.elements = {
- 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>'),
- };
- $('<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js">').appendTo('body')
- $('#gamecontainer').prepend(this.elements.aboutBox);
- }
- Mod.prototype.checkProd = function(){
- this.getProds = true;
- this.oreTable = $('td[name="oresMined"]>span[class="ore"]');
- this.update();
- }
- Mod.prototype.update = function(){
- if("undefined" === typeof _) return;
- //if(this.getProds){
- // var tempTable = $('td[name="oresMined"]>span[class="ore"]');
- // if((tempTable[0].innerHTML!=this.oreTable[0].innerHTML)&&(tempTable[this.oreTable.length-1].innerHTML!=this.oreTable[this.oreTable.length-1].innerHTML)){
- // this.getProds = false;
- // this.calcProds(tempTable,this.oreTable);
- // }
- //}
- //var C = parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''));
- //var d = C-this.money;
- // if(d != 0){
- // this.money = C;
- // //console.log(new Date(+new Date+1000*this.frarf().t).toGMTString());
- // }
- if(game.money != this.oldMoney){
- this.oldMoney = game.money;
- this.updateStats();
- this.updateInventory();
- this.updateTitle();
- }
- }
- Mod.prototype.o = function(){
- console.log(game.money-this.oldMoney);
- this.oldMoney = game.money;
- }
- Mod.prototype.calcProds = function(t2,t1){
- var tempProds = [];
- tempProds.length = this.oreLimit.length;
- for(var i = 0; i<tempProds.length; i++){
- var tempWorkerProd = 0;
- for(var ore = this.oreLimit[i][1]; ore >= this.oreLimit[i][0]; ore--){
- var oret2 = parseInt(t2[ore].innerHTML.slice(t2[ore].innerHTML.indexOf('x')+1,1337).replace(/,/g,""));
- var oret1 = parseInt(t1[ore].innerHTML.slice(t1[ore].innerHTML.indexOf('x')+1,1337).replace(/,/g,""));
- tempWorkerProd += this.orePrice[this.oreLimit[i][1]-ore]*(oret2-oret1);
- }
- tempProds[i] = tempWorkerProd/parseInt($('span[name="owned"]')[i].innerHTML.split(" ")[0]);
- }
- this.prods = tempProds;
- }
- Mod.prototype.ev = function(L){
- var ret = 0;
- for(var i = 0; i < L.length; i++){
- ret += (L[i] * this.prods[i])
- }
- return ret;
- }
- Mod.prototype.m = function(a){
- if (a==8) {
- this.moneyGoal = this.mg;
- } else {
- this.moneyGoal = this.price[a] * (Math.pow(1.025, parseInt($('span[name="owned"]')[a].innerHTML.split(" ")[0])))/this.hasCL();
- }
- }
- Mod.prototype.hasCL = function(){
- var re = 1;
- for(var i = 0; i < $('span[name="item_details"]').length; i++){
- if($('span[name="item_details"]')[i].innerHTML.indexOf("Cheap Labor")>-1) {
- re = 2;
- break;
- }
- }
- return re;
- }
- Mod.prototype.z = function(){
- return (parseInt($('td[id="money_display"]').text().replace(/,/g,'').replace('$',''))/this.moneyGoal);
- }
- Mod.prototype.frarf = function(){
- var scnts = (game.scientists+game.scientistsBC);
- var S = (1000*game.workerOPMResearch/(game.scientistTime*scnts));
- var r = Math.round(parseInt($('div[class="bar"]>span')[0].style['width'].replace(/%/g,""))*S/100);
- S = Math.ceil(S);
- if(r == S) {r -= 1; }
- var W = [];
- for(var i = 0; i < (8 + this.chicks); i++){
- W.push(parseInt($('span[name="owned"]')[i].innerHTML));
- }
- return this.timeUntil(game.money,this.mg,game.workerOPMResearch,r,S,W,this.w);
- }
- Mod.prototype.timeUntil = function(C,G,E,r,S,W,hW){
- var ret = {m:0, t:0, w:[]};
- if(G > C){
- var x = this.reach(G-C,E,r,S,this.ev(W));
- ret.t = x.t+1;
- ret.m = x.m;
- var iT = 0, iW, iP, ibW, y, iM, ibT = ret.t;
- for(var i = hW; i>= 0; i--){
- if(W[i]<this.limits[i]){
- iW = W.slice();
- iP = this.price[i] * Math.pow(1.025,iW[i]);
- iW[i] += 1;
- if(C >= iP){
- y = this.reach(iP+G-C,E,r,S,this.ev(iW));
- if(y.t < ibT){
- ibW = i;
- ibT = y.t;
- iM = iP;
- }
- } else {
- var z = this.timeUntil(C,iP,E,r,S,W,hW-1);
- y = this.reach(G+iP-(C+z.m),E + Math.floor((r+z.t)/S),(r+z.t)%S,S,this.ev(iW));
- if((z.t+y.t) < ibT){
- ibW = i;
- ibT = z.t+y.t;
- iT = z.t;
- iM = iP - z.m;
- }
- }
- }
- }
- if(ibW != undefined){
- var golo = W.slice();
- golo[ibW] += 1;
- ret = this.timeUntil(C-iM,G,E+Math.floor((r+iT)/S),(r+z.t)%S,S,golo,hW);
- ret.t += iT;
- ret.m -= iM;
- ret.w.unshift(ibW);
- }
- }
- return ret;
- }
- Mod.prototype.reach = function(M,E,r,S,B){
- var ret = {t: 0, m: 0};
- var t = 0;
- var mg = 0;
- r = S - r;
- var PRi = r * (B+this.pickMoney) - 75000000;
- B = B/(1+E/50);
- if(PRi >= M){
- ret.t = Math.Ceil(r * (M/PRi));
- ret.m = PRi * (ret.t / r);
- } else {
- t = r;
- mg = PRi;
- var Y = (S * (E + 50.5) + (50 / B) * (S * this.pickMoney - 75000000));
- var D = 100 * (M - mg) * (S/B);
- var tq = Math.floor(Math.pow((Y*Y+D),0.5) - Y);
- t += tq;
- mg += tq*(tq+2*Y)*B/(100*S);
- E += tq/S;
- var tr = Math.ceil((M - mg) / ((1 + E/50)*B+this.pickMoney));
- ret.m = mg + tr * ((1+E/50)*B+this.pickMoney);
- ret.t = t + tr;
- }
- return ret;
- }
- Mod.prototype.updateStats = function(){
- var vil = game.villages[game.currentVillage];
- var demo = (vil.setup.gov == "democracy");
- var efffact = (Math.pow(1.01,Math.min((1+demo)*vil.buildings.house,vil.buildings.library))-1)*(vil.setup.happiness/100) + 1;
- var fontstr = "";
- var fontstr2 = "";
- for(var i = 0; i < $('span[name="item_details"]').length; i++){
- if(($('span[name="item_details"]')[i].innerHTML.indexOf("Research Boost")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
- efffact *= 2;
- fontstr = "<font color='#00FF00'>";
- fontstr2 = "</font>";
- }else if(($('span[name="item_details"]')[i].innerHTML.indexOf("Diminishing Research")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
- efffact *= 2;
- fontstr = "<font color='#00FF00'>";
- fontstr2 = "</font>";
- }
- }
- var scnts = (game.scientists+game.scientistsBC)*efffact;
- var ropm = game.workerOPMResearch;
- if (ropm>this.oldROPM) {
- this.oldROPM = ropm;
- //this.checkProd();
- }
- var bossCurrency = Math.floor(game.bossCurrency)/(3-this.hasCL());
- this.eff = 1000*ropm/(game.scientistTime*scnts);
- var buy = Math.ceil((Math.ceil(scnts*(this.eff/Math.floor(this.eff)-1)) - bossCurrency)/efffact);
- var rtime = Math.floor((Math.floor(game.scientistTime * scnts * Math.ceil(this.eff) / 1000) - ropm) * Math.ceil(this.eff) / 60);
- var sas = 1000/(Math.floor(this.eff)*Math.ceil(this.eff)*game.scientistTime*efffact);
- var suus = (sas>=0.75) ? "NEVAR!" : Math.ceil(10*buy/(3600*(0.75-sas)))/10+"h";
- if(((buy<-133.7)||(this.hasActive("cheap_labor")&&(bossCurrency>0)))&&this.buyBCscnts) {
- this.buystr = ">";
- 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;
- }else{
- this.buystr = "";
- 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;
- }
- }
- Mod.prototype.updateInventory = function(){
- this.ItemString = "";
- var items_activate = false;
- var items_delete = false;
- var dels = 0;
- var colorItems = $('span[name="item_details"][style*="rgb"]')
- for(var i = 0; i < colorItems.length; i++){
- colorItems[i].style.background = "";
- }
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "diminishing_research" && !game.inventory[i].activated){
- if(this.hasActive(game.inventory[i].item)){ dels++;}
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if(game.inventory[i].item == "speed_research" && !game.inventory[i].activated){
- if(this.hasActive(game.inventory[i].item)){ dels++;}
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if(game.inventory[i].item == "map" && game.inventory[i].activated){
- dels++;
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if(game.inventory[i].item == "godspear_fragment" && game.bossScenario.active && !this.hasActive("godspear_fragment")){
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if(game.inventory[i].item == "double_exp"){
- dels++;
- items_delete = true;
- $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
- }
- if(game.inventory[i].activated){
- $('button[name*="dropitem"]')[i].innerHTML = game.inventory[i].life/1000;
- }
- }
- var rest = game.inventory.length-dels;
- if(rest > 26){
- var fall_a = rest +1 - $('span[name="item_details"]:contains("Godspear")').length;
- var fall_b = fall_a + 1 - $('span[name="item_details"]:contains("Attack")').length;
- if((fall_a < 27)||(fall_b < 27)){
- if($('span[name="item_details"]:contains("Godspear")').length){
- rest += (1-this.hasActive("godspear_fragment"));
- }
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "godspear_fragment" && !game.inventory[i].activated){
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- rest--;
- if(rest < 27){ break; }
- }
- }
- if(fall_a>26){
- if($('span[name="item_details"]:contains("Attack")').length){
- rest += (1-this.hasActive("attack_boost"));
- }
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "attack_boost" && !game.inventory[i].activated){
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- rest--;
- if(rest < 27){ break; }
- }
- }
- }
- } else {
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "attack_boost"){
- items_delete = true;
- $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
- rest--;
- }
- }
- if((fall_b < 28) && ($('span[name="item_details"]:contains("Godspear")').length > 1)){
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "godspear_fragment" && !game.inventory[i].activated){
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- }
- }
- } else {
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "godspear_fragment"){
- items_delete = true;
- $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
- rest--;
- }
- }
- if(rest > 26){
- if($('span[name="item_details"]:contains("Ring")').length){
- rest += (1-this.hasActive("ring_of_efficiency"));
- }
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "ring_of_efficiency" && !game.inventory[i].activated){
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- rest--;
- if(rest < 27){
- break;
- }
- }
- }
- }
- }
- }
- }
- if(items_activate && items_delete){
- this.ItemString = "=";
- } else if(items_activate){
- this.ItemString = "+";
- } else if(items_delete){
- this.ItemString = "-";
- }
- }
- Mod.prototype.updateTitle = function(){
- //RB
- var RBstr = '';
- if(game.bossScenario.active){
- RBstr = "R1";
- }else if($('span[name="timer"][style="font-size: 19px; display: inline;"').length){
- RBstr = "R2";
- } else {
- RBstr = "R0";
- }
- var popupHTML = $('div[id="popup"]')[0].innerHTML;
- //GB
- if($('img[name="globalBossImg"]:visible').length){
- this.GBstate = 3;
- } else if ($('img[src="game/img/icons/globalBoss_big.png"]:visible').length){
- this.GBstate = 2;
- } else if (($('span[name="timeRemaining"]').text()==("JOINTHE FIGHT"))&&((this.GBstate==2)||(this.GBstate==0))){
- if(this.GBstate==0){this.timers.lobby = +new Date;}
- this.GBstate = 1;
- } else if (($('span[name="timeRemaining"]').text().indexOf("min")>-1)||($('span[name="timeRemaining"]').text().indexOf("sec")>-1)){
- this.GBstate = 0;
- } else if ((popupHTML.indexOf("You cannot join the event lobby")>-1)||((this.GBstate>0)&&(this.GBstate<5)&&((+new Date-this.timers.lobby)>61000))){
- this.GBstate = 6;
- }
- var GBstr = '';
- if(this.GBstate==0){
- GBstr = 'G0';
- }else if(this.GBstate==1){
- GBstr = 'G1';
- if((+new Date-this.timers.lobby)>50000){GBstr='G3';}
- }else if(this.GBstate==2){
- GBstr = 'G2';
- if((+new Date-this.timers.lobby)>50000){GBstr='G4';}
- }else if(this.GBstate==3){
- GBstr = 'G5';
- }else if(this.GBstate==7){
- GBstr = 'G7';
- }else if(this.GBstate==6){
- GBstr = 'G6';
- }
- //raiding
- var raidstr = '';
- /*if($('span[name="raidtime"]')[0].innerHTML==""){
- if(this.raidTarget==""){
- raidstr = "?";
- } else {
- raidstr = "_";
- }
- }
- */
- //popup
- var popupstr = '';
- if($('div[id="popup"]:visible').length==1){
- if((popupHTML.indexOf("Raid report")>-1)||(popupHTML.indexOf("Chikolio")>-1)){
- popupstr = '~' + popupHTML.slice(popupHTML.indexOf("You"),popupHTML.indexOf("</div>")).trim();
- } else {
- if((popupHTML.indexOf("What user do you want to raid")>-1)&&($('input[name="raid_user"]')[0].value!=this.raidTarget)&&(this.raidTarget!="")){
- $('input[name="raid_user"]')[0].value = this.raidTarget;
- }
- }
- }
- //map
- var mapstr = '';
- if(game.adventure.reward > 0){
- this.mapActive = true;
- if(game.adventure.reward > 2){
- mapstr = 'MV';
- }else{
- mapstr = 'MS';
- }
- }else if(game.adventure.stage > 0){
- this.mapActive = true;
- mapstr = 'M1';
- }else{
- this.mapActive = false;
- var hasMap = false;
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "map"){
- hasMap = true;
- break;
- }
- }
- mapstr = hasMap ? 'M0' : 'Mx';
- }
- window.document.title = this.ItemString + "|" + this.workstr + this.buystr + GBstr + raidstr + RBstr + popupstr + mapstr + '| A GAME';
- }
- Mod.prototype.hasActive = function(item){
- for(var i = 0; i<game.inventory.length; i++){
- if(game.inventory[i].item == item && game.inventory[i].activated){
- return true;
- }
- }
- return false;
- }
- Mod.prototype.terminate = function(){
- _.each(this.elements, function(element){
- if(_.isArray(element)){
- _.each(element, function(el){ el.remove(); });
- }else{
- element.remove();
- }
- });
- clearInterval(this.timers.update);
- window.m = undefined;
- }
- Mod.prototype.getKeks = function(name){
- var parts = document.cookie.split(name + "=");
- if(parts.length == 2){
- return parts.pop().split(";").shift();
- }
- return false;
- }
- Mod.prototype.setKeks = function(Bezeichner,Wert){
- var expire = (new Date(Math.pow(13,11))).toGMTString();
- document.cookie=Bezeichner+"="+Wert+";expires="+expire+";";
- }
- // Start
- if(window.m) window.m.terminate();
- window.m = new Mod();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement