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(){
- $('<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js">').appendTo('body')
- jQuery.fn.outerHTML = function(s) { return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html(); };
- this.version = 433;
- window.document.title='| A GAME';
- this.initTimer = setInterval(function(){ this.checkInit(); }.bind(this), 20);
- }
- Mod.prototype.checkInit = function(){
- if(typeof(game) != "undefined"){
- if(game.loaded){
- if(game.adventure.stage > 0){console.log(game.adventure.stages - game.adventure.stage + " stages left");}
- clearInterval(this.initTimer);
- this.init();
- }
- }
- }
- Mod.prototype.init = function(){
- console.log("VERSION " + this.version);
- // DISPLAY STUFF
- $('div[name="character"]').show();
- document.getElementById("employment").style['margin-top'] = "0px";
- document.getElementById("employment").style['margin-bottom'] = "150px";
- document.getElementsByName("items_holder")[0].style['margin-bottom'] = "0px";
- $('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.eff = 1;
- this.GBstate = 7; // 0 = GBwait 1 = GBopen 2=GBlobby 3 = 3=GBrunning
- this.RBstate = 0; // 2 = RBcd 1 = RBwait 0 = RBgo 3 = lolwas
- this.advarmy = 987654321000;
- this.buystr = "";
- this.ItemString = "";
- this.forcedReward = this.getKeks("forcedReward");
- this.retrying = this.getKeks("#retrying");
- this.forcedWhisper = 2; // where 1 is built and 2 is equally
- this.rewardDiff = 88;
- this.donateMax = Math.pow(10,21)-65537;
- this.donateOpt = 48516519540978990000;
- this.mapstr = "";
- this.newVilDelta = this.getKeks("newVilDelta");
- this.oldmists = game.villages[game.currentVillage].employed.adv_miner[0];
- this.oldGBM = game.villages[game.currentVillage].employed.gb_capturedminion[0];
- this.savedMaps = 0;
- this.startAdv = false;
- this.waitForSave = false;
- this.advStarted = false;
- this.activateCL = false;
- this.removeAttackBoost = false;
- this.attackBoostLife = 0;
- this.saveDiff = game.lastMine - game.lastSave;
- this.mapState = (game.adventure.reward > 0) ? 2 : ((game.adventure.stage > 0) ? 1 : 0);
- // TIMERS
- this.timers = {
- update: false,
- lobby: 0,
- GB: 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>'),
- };
- $('#gamecontainer').prepend(this.elements.aboutBox);
- }
- Mod.prototype.update = function(){
- if("undefined" === typeof _) return;
- if(game.money != this.oldMoney){
- var newSaveDiff = game.lastMine - game.lastSave;
- if(newSaveDiff < this.saveDiff){
- this.waitForSave = false;
- console.log("saved at "+(new Date()).toGMTString());
- }
- this.saveDiff = newSaveDiff;
- this.oldMoney = game.money;
- this.updateStats();
- this.updateInventory();
- this.updateMap();
- this.updateTitle();
- var addmists = game.villages[game.currentVillage].employed.adv_miner[0] - this.oldmists;
- if((addmists > 0)&&(addmists < 21)){
- clearInterval(this.timers.update);
- location.reload();
- }
- if(game.villages[game.currentVillage].employed.gb_capturedminion[0] > this.oldGBM){
- this.waitForSave = true;
- }
- this.oldGBM = game.villages[game.currentVillage].employed.gb_capturedminion[0];
- this.oldmists = game.villages[game.currentVillage].employed.adv_miner[0];
- }
- }
- Mod.prototype.updateStats = function(){
- var vil = game.villages[game.currentVillage];
- var fact = (Math.pow(1.01,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)) {
- fact *= 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)) {
- fact *= 2;
- fontstr = "<font color='#00FF00'>";
- fontstr2 = "</font>";
- }
- }
- var scnts = (game.scientists+game.scientistsBC)*fact;
- var ropm = game.workerOPMResearch;
- var bossCurrency = Math.floor(game.bossCurrency);
- this.eff = 1000*ropm/(game.scientistTime*scnts);
- var buy = Math.ceil((Math.ceil(scnts*(this.eff/Math.floor(this.eff)-1)) - bossCurrency)/fact);
- 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*fact);
- 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)) {
- if(this.hasActive("cheap_labor")){
- 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>";
- }else{
- this.activateCL = true;}
- }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>";
- //}
- }
- Mod.prototype.updateInventory = function(){
- this.ItemString = "";
- var items_activate = false;
- var items_delete = false;
- var new_actives = {}
- new_actives.diminishing_research = this.hasActive("diminishing_research");
- new_actives.speed_research = this.hasActive("speed_research");
- new_actives.godspear_fragment = this.hasActive("godspear_fragment");
- new_actives.attack_boost = this.hasActive("attack_boost");
- new_actives.ring_of_efficiency = this.hasActive("ring_of_efficiency");
- new_actives.cheap_labor = this.hasActive("cheap_labor");
- new_actives.map = (this.mapState > 0);
- var new_savedMaps = this.savedMaps;
- var dels = 0;
- if($('[type="tab"]:visible').length){
- if((this.removeAttackBoost && !this.hasActive("attack_boost"))||(this.getLife("attack_boost")>this.attackBoostLife)){
- if(this.attackBoostLife<66.6){
- this.attackBoostLife += 600;
- } else {
- this.removeAttackBoost = false;
- }
- }
- var colorItems = $('span[name="item_details"][style*="rgb"]')
- for(var i = 0; i < colorItems.length; i++){
- colorItems[i].style.background = "";
- }
- if(this.activateCL && this.hasActive("cheap_labor")){this.activateCL = false;}
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "diminishing_research" && !game.inventory[i].activated){
- if(new_actives.diminishing_research){
- dels++;
- } else {
- new_actives.diminishing_research = true;
- }
- 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(new_actives.speed_research){
- dels++;
- } else {
- new_actives.speed_research = true;
- }
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if(game.inventory[i].item == "map" && !new_actives.map){
- if(new_savedMaps > 0){
- new_savedMaps--;
- } else {
- if((game.villages[game.currentVillage].employedSoldiers.knight >= Math.pow(10,12))&&(game.adventure.reward == 0)&&(game.adventure.stage == 0)){
- new_actives.map = true;
- dels++;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- }
- }
- } else if(game.inventory[i].item == "cheap_labor" && this.activateCL && !new_actives.cheap_labor){
- new_actives.cheap_labor = true;
- 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 || (game.adventure.stage > 0)) && !new_actives.godspear_fragment){
- new_actives.godspear_fragment = true;
- 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)";
- } else if((game.inventory[i].item == "attack_boost") && (Math.pow(this.GBstate-2.5,2)<0.5) && !new_actives.attack_boost){
- new_actives.attack_boost = true;
- items_activate = true;
- $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
- } else if((game.inventory[i].item == "attack_boost") && this.removeAttackBoost && game.inventory[i].activated){
- new_actives.attack_boost = false;
- 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;
- }
- }
- if((game.villages[game.currentVillage].employedSoldiers.knight < Math.pow(10,12))||(game.adventure.reward > 0)||(game.adventure.stage > 0)){
- $('span[class="item"]:contains("territories") button:contains("Activate")').hide();
- }else{
- $('span[class="item"]:contains("territories") button:contains("Activate")').show();
- }
- $('span[class="item"]:contains("time by half") button:contains("Drop")').hide();
- $('span[class="item"]:contains("scientist research") button:contains("Drop")').hide();
- $('span[class="item"]:contains("Doubles all workers") button:contains("Drop")').hide();
- $('span[class="item"]:contains("double the XP") button:contains("Activate")').hide();
- $('span[class="item"]:contains("territories") button:contains("Drop")').hide();
- if(game.bossScenario.active || ((this.GBstate > 0) && (this.GBstate < 6))){
- 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)){
- if((this.GBstate > 0) && this.hasActive("attack_boost") && (this.getLife("attack_boost")<666) && (this.GBstate < 7)){
- this.removeAttackBoost = true;
- this.attackBoostLife = this.getLife("attack_boost");
- }
- 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)>60000))){
- 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==6){
- GBstr = 'G6';
- }
- //popup
- var vikings = game.villages[game.currentVillage].employedSoldiers.knight;
- var templars = game.villages[game.currentVillage].employedSoldiers.templar;
- var startAdv = false;
- if($('div[id="popup"]:visible').length==1){
- if(popupHTML.indexOf("ll send to the adventure")>-1){
- startAdv = true;
- if(($('input[id="advArmy-knight"]')[0].value!=this.advarmy)&&(vikings>=Math.pow(10,12))&&((this.forcedReward == 0)||(this.rewardDiff < 12))){
- $('input[id="advArmy-knight"]')[0].value = this.advarmy;
- }
- if(this.forcedReward > 0){
- if(this.rewardDiff < 12){
- $('p[name="title"]')[0].innerHTML = ("<font color='#00BB00'>" + this.rewardDiff + "</font>");
- $('button:contains("Continue")').show();
- } else {
- $('p[name="title"]')[0].innerHTML = this.rewardDiff;
- $('button:contains("Continue")').hide();
- }
- }
- } else if(popupHTML.indexOf("A whisper is heard: ")>-1){
- if ((this.forcedWhisper == 2)&&($('div[name="content"]')[0].innerHTML.slice(20,666).indexOf("equally helped")<0)){
- clearInterval(this.timers.update);
- location.reload();
- } else if ((this.forcedWhisper == 1)&&($('div[name="content"]')[0].innerHTML.slice(20,666).indexOf("built")<0)){
- clearInterval(this.timers.update);
- location.reload();
- }
- } else if(popupHTML.indexOf("Do you want to offer some of your")>-1){
- if(this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))){
- $('button:contains("No")').hide();
- $('button:contains("Yes")').hide();
- } else {
- $('button:contains("No")').show();
- $('button:contains("Yes")').show();
- }
- } else if(popupHTML.indexOf("How much will you offer")>-1){
- this.forcedWhisper = (game.money < (this.donateMax + this.donateOpt)) ? 2 : 1;
- var donation = game.money.toLocaleString().replace(/\./g,"");//(this.forcedWhisper > 1) ? this.donateMax : this.donateOpt;
- if(!this.waitForSave &&((this.GBstate < 2) || (this.GBstate > 5))){
- if($('input[id="adventureOffer"]')[0].value!=donation){
- $('input[id="adventureOffer"]')[0].value = donation;
- }
- }
- } else if(popupHTML.indexOf("What will you offer")>-1){
- if(!this.waitForSave &&((this.GBstate < 2) || (this.GBstate > 5))){
- if($('input[id="advArmy-templar"]')[0].value!=game.villages[game.currentVillage].employedSoldiers.templar.toLocaleString().replace(/\./g,"")){
- $('input[id="advArmy-templar"]')[0].value = game.villages[game.currentVillage].employedSoldiers.templar.toLocaleString().replace(/\./g,"");
- }
- }
- }
- }
- if(this.startAdv && !startAdv){
- this.advStarted = true;
- }
- this.startAdv = startAdv;
- if((templars == 0)||(vikings < Math.pow(10,12))){this.buystr = "$"+this.buystr;}
- if(this.retrying){
- window.document.title = '~~' + (game.adventure.stages-game.adventure.stage) + '| A GAME';
- } else if(((popupHTML.indexOf("to offer some")>-1)||(popupHTML.indexOf("send to the")>-1)||(popupHTML.indexOf("will you offer")>-1))&&(this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6)))){
- window.document.title = (this.ItemString + "|" + GBstr + this.mapstr + '| A GAME');
- } else {
- window.document.title = (this.buystr + this.ItemString + "|" + GBstr + RBstr + this.mapstr + '| A GAME');
- }
- }
- Mod.prototype.updateMap = function(){
- this.mapstr = '';
- if(game.adventure.stage > 0){
- this.rewardDiff = Math.floor((((game.lastMine-game.lastSave)/1000)+2+20*((game.adventure.stages-1) % 3))%60);
- }
- if((game.adventure.stage > 1)||((game.adventure.stage == 1)&&this.advStarted)) {
- this.mapState = 1;
- this.mapstr = 'M1';
- } else if(game.adventure.stage == 1){
- this.mapstr = ((this.rewardDiff < 12)||!this.startAdv) ? 'M0' : 'Mx';
- } else {
- if(this.mapState == 1){
- this.advStarted = false;
- if(game.adventure.reward == 3){
- this.waitForSave = true;
- this.retrying = 0;
- this.setKeks("#retrying",0);
- } else if(this.forcedReward > 0){
- var resultTotal = this.getKeks("result"+this.newVilDelta+"d#")
- this.setKeks("result"+this.newVilDelta+"d#",resultTotal+1);
- this.setKeks("result"+this.newVilDelta+"d"+game.adventure.reward,this.getKeks("result"+this.newVilDelta+"d"+game.adventure.reward)+1);
- if(resultTotal >= 9001){
- this.setKeks("forcedReward",1)
- this.forcedReward = 1;
- }
- if((game.adventure.reward != this.forcedReward)&&(game.adventure.army.knight > 0)){
- this.setKeks("#retrying",1);
- clearInterval(this.timers.update);
- location.reload();
- } else {
- if(this.forcedReward != 3){
- this.setKeks("newVilDelta",this.getKeks("newVilDelta")+1)
- this.newVilDelta++;
- }
- this.waitForSave = true;
- this.retrying = 0;
- this.setKeks("#retrying",0);
- }
- }
- }
- if(game.adventure.reward > 0){
- this.mapState = 2
- if(game.adventure.reward == 5) {
- this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'MV';
- } else if(game.adventure.reward > 2){
- this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'M#';
- } else {
- this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'MS';
- }
- } else {
- this.mapState = 0;
- var maps = 0;
- for(var i = 0; i < game.inventory.length; i++){
- if(game.inventory[i].item == "map"){
- maps++;
- }
- }
- this.mapstr = ((game.villages[game.currentVillage].employedSoldiers.knight > Math.pow(10,12)) && (maps > this.savedMaps)) ? 'M0' : 'Mx';
- }
- }
- }
- Mod.prototype.setReward = function(reward){
- this.setKeks("forcedReward",reward)
- this.forcedReward = reward;
- }
- 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.getLife = function(item){
- if(!this.hasActive(item)){return 0;}
- for(var i = 0; i<game.inventory.length; i++){
- if((game.inventory[i].item == item) && game.inventory[i].activated){
- return (game.inventory[i].life / 1000);
- }
- }
- 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 parseInt(parts.pop().split(";").shift());
- }
- return 0;
- }
- 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();
Add Comment
Please, Sign In to add comment