Verified:

TheMafia Game profile

Member
62

May 20th 2015, 4:36:15

=================What it does (INSTALLATION STEPS BELOW) ================

Score Board: http://tcpm.mrlazyinc.com/..._monkey_script_scores.PNG
Portal Leader Boards: http://tcpm.mrlazyinc.com/...monkey_script_leaders.PNG
Market (v2): http://tcpm.mrlazyinc.com/..._monkey_script_market.PNG
Research (v3): http://tcpm.mrlazyinc.com/...onkey_script_research.PNG
Browser Tab Title (v3): http://tcpm.mrlazyinc.com/..._script_browser_title.PNG
Buildings (v4): http://tcpm.mrlazyinc.com/...nkey_script_buildings.PNG

NEW: -- Building Percentage (v6.8): http://tcpm.mrlazyinc.com/...key_script_build_perc.PNG -- :NEW
NEW: -- Turns Left (v6.5): http://tcpm.mrlazyinc.com/...key_script_turns_left.PNG -- :NEW
NEW: -- Spy (v6): http://tcpm.mrlazyinc.com/...y_script_spy_military.PNG -- :NEW

This script calculates networth per acre of the people around you in the scores page. It then displays this number to you and also highlights some players that might be of interest to you, for either attacking or defending from. Check out the screen shots below for details. Remember to put your player name into the script.
Player GOV type is moved next to the players name

=============================Latest===============================
Version 6.95:
-Explore automatically adds '1' to field instead of default of '0'

Version 6.9:
-minor fix for building percentages (total count was off)

Version 6.8:
-New feature: in building page you will now see the percentage each building type occupies on your land.
--Total land is now displayed above the percentages column (see pic)

Version 6.5:
-"Turns Left" added to main page (picture above)
--based on the server you are playing on, the script will try to estimate how many turns you can expect in the future from this moment on.


!Version 6.1:
-fixed calculations to show:
--Defence Points
--Minimum Jets to send

Version 6:
-SPY Page:
--When you've spied on a country a new field should show up at the end of the 'Military Forces' called 'Min. Attack'
--This is a VERY simple calculation, troops /2 + turrets + tanks *4
--NOT PART OF THE CALCULATION: Gov type and weapon research

================================================================

Version 5.5 - Recent updates and Market click fix:
-When hovering in market, you will see total cost of the units you hovered over.
Now:
Clicking will populate the buy field with the amount you just hovered over ( so if you hovered over 200,000 turrets, the cost will show up, then when you click it 200,000 will get populated into the buy field)

-Minor updates to scores display
--net/acre that are nearly half of your net/acre will show up in red too




Version 4:
-The buildings page now has the same functionality as the research page in version 3.

Version 3 - Research and more:
-Research tools have been created
-Both market and scores pages refresh on a 1 minute basis now
-Some changes to how the title displays in the browser, now shows: R:[Rank] (if available) T:(Turns) M:$Money
-Minor bug fixes

Version 2 - Market Additions:
When you mouse over the yellow columns, for any product, that amount is multiplied by the market value and displayed to you in the input field on the right. (i have stretched the field to fit billion dollar figures)
This applies to:
-Buy goods
-Buy Tech





========================Setup==========================
Required:
Browser (like chrome) with a javascript auto execute add on (like 'TamperMonkey', google it) or equvilent
add on needs to support including jQuery library

What you need to do:
Lets say you use tamperMonkey and chrome.
-Open the dashboard for tampermonkey
-start a new script
-copy the script from below into the new page.


Script (last update: Aug 26, 2015):

// ==UserScript==
// @name EarthEmpires - Assit Tools and Calculations
// @namespace http://www.steamLazy.com/
// @version 6.95
// @author TheMafia
// @match *://*.earthempires.com/*
// @match *://earthempires.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==


var currentPage = window.location.href;
var turns = jQuery(".topbar td:contains('Turns:')").last().text().replace("Turns: ", "");
var money = jQuery(".topbar td:contains('Money:')").last().text().replace("Money: ", "");
document.title = "T:("+ turns + ")" + "M:"+ money;

if ((currentPage.indexOf("scores") > 0 || (currentPage.indexOf("market") > 0 && currentPage.indexOf("sell") < 1)) && currentPage.indexOf("forum") <= 0) {
var intv = setTimeout(function(){
var curPage = window.location.href;
window.location = curPage;
}, 60000);
}

if (currentPage.indexOf("explore") > 0){
//Add 1 to field
jQuery("input[name='turns']").val(1);

}


if (currentPage.indexOf("spy") > 0){
//Check if spied
if (jQuery("th:contains('Military Forces')").length > 0){
var parentBody = jQuery("th:contains('Military Forces')").parent().parent();
jQuery(parentBody).append("<tr><td>Defence Points</td><td class='rt' id='forceCalc'></td></tr>");
jQuery(parentBody).append("<tr><td>Min Jets Hit:</td><td class='rt' id='jetCalc'></td></tr>");

var troops = parseInt(jQuery(parentBody).find("tr").eq(2).find("td").eq(1).text().replace(",","").replace(",","")) ;
var turrets = parseInt(jQuery(parentBody).find("tr").eq(4).find("td").eq(1).text().replace(",","").replace(",",""));
var tanks = parseInt(jQuery(parentBody).find("tr").eq(5).find("td").eq(1).text().replace(",","").replace(",",""));
console.log("1: "+ troops + " -2:"+ turrets +" -3:"+ tanks);

var attackMin = (troops) + turrets*2 + (tanks *4);
var jetMin = attackMin / 2;
jQuery("#forceCalc").text(attackMin);
jQuery("#jetCalc").text(jetMin);
}
}


if (currentPage.indexOf("main") > 0){
//Check if spied
var serverType = jQuery("td:contains('Server')").next("td").text();
var timeLeft = jQuery("#maintable").next().next().text();
var turnsLeft = 0;
var timeInterval = 1;
switch(serverType){
case "Express":
timeInterval = 4;
break;
case "Tournament":
timeInterval = 25;
break;
case "Primary":
timeInterval = 30;
break;
case "Team":
timeInterval = 15;
break;
case "Alliance":
timeInterval = 20;
break;
case "Free For All":
timeInterval = 20;
break;
}

if (timeLeft.indexOf("hours") > 0){
timeLeft = timeLeft.replace("The reset ends in ", "");
timeLeft = timeLeft.replace("hours.", "");
turnsLeft = (60 * parseFloat(timeLeft)) / timeInterval;
}else if (timeLeft.IndexOf("days") > 0){
timeLeft = timeLeft.replace("The reset ends in ", "");
timeLeft = timeLeft.replace("hours.", "");
turnsLeft = (60 * 24 *parseFloat(timeLeft)) / timeInterval;
}
jQuery("#maintable").next().next().append("<br>Turns left: "+ turnsLeft);
}




if (currentPage.indexOf("market") > 0){
//Init settings
jQuery("table.contenttable tr").children("td:nth-child(7)").find("input").css({"width":"95px"});
jQuery("table.contenttable tr").children("td:nth-child(1)").each(function(){
jQuery(this).html(jQuery(this).html().replace("Military", "Mil."));
});
//jQuery(this).closest("tr").children("td:nth-child(7)").find("input").css({"width":"90px"});

var tempNum = 0;
var tempVal = 0;
var cashAmount = "";
var tax = 1 + (jQuery(".mTax").html().replace("%", "").toLocaleString() / 100);
jQuery("table.contenttable tr").has("td.lt").each(function(){
jQuery(this).find("td:nth-child(5), td:nth-child(6), td:nth-child(2)").hover(
function(){
tempNum = jQuery(this).html();
tempVal = jQuery(this).closest("tr").children("td:nth-child(7)").find("input").val();

cashAmount = "$" + Math.ceil((Math.round(jQuery(this).closest("tr").children("td:nth-child(3)").find("input").val()) * Math.round(jQuery(this).html().replace(",", "").replace(",", "").replace("$", "")) * tax)).toLocaleString();
//jQuery(this).html(cashAmount);
jQuery(this).closest("tr").children("td:nth-child(7)").find("input").val(cashAmount);

}, function(){
//jQuery(this).html(tempNum);
jQuery(this).closest("tr").children("td:nth-child(7)").find("input").val(tempVal);

}
).click(function(){
tempVal = jQuery(this).html(); //jQuery(this).closest("tr").children("td:nth-child(7)").find("input").val();
});
});
}

if (currentPage.indexOf("scores") > 0 || currentPage.indexOf("ranks") > 0 || currentPage.indexOf("clans") > 0){
var self = jQuery("td.c-own").html().split("(")[1].replace(")","");
var land = 0;
var networth = 0;
var perAcre = 0;
var rank = 0;
var selfPer = 0;
var selfLand = 0;
var selfNet = 0;
var selfRank = 0;

jQuery("p:contains('server.')").append(" <a target='_blank' href='http://www.eestats.com/';;>EeStats</a>");

jQuery(".lt").each(function(){
if(jQuery(this).html().indexOf(self) > 1){
jQuery(this).css({"color":jQuery(this).find("td:nth-child(2)").css("color")});
selfRank = Math.round(jQuery(this).find("td:first").html());
document.title = "R:["+ selfRank +"]" + document.title;

jQuery(this).find(".rt").each(function(){
if (land === 0){
land = Math.round(jQuery(this).html().replace(",", "").replace(",", ""));
}else{
networth = Math.round(jQuery(this).html().replace(",", "").replace(",", "").replace("$", ""));
}
});
selfPer = Math.round(networth / land);
selfLand = Math.round(land);
selfNet = Math.round(networth);
}
});

jQuery(".lt").each(function(){
land = 0;
networth = 0;
perAcre = 0;
rank = 0;

jQuery(this).find("td:nth-child(2)").append(" ["+ jQuery(this).find(".ct").html() +"]");

rank = Math.round(jQuery(this).find("td:first").html());
jQuery(this).find(".rt").each(function(){
if (land === 0){
land = Math.round(jQuery(this).html().replace(",", "").replace(",", ""));
}else{
networth = Math.round(jQuery(this).html().replace(",", "").replace(",", "").replace("$", ""));
}
});
perAcre = Math.round(networth / land);
jQuery(this).find(".ct").html(perAcre);

if ((networth / 2) <= selfNet && (selfNet / 2) <= networth){
jQuery(this).find(".rt:eq(1)").css({"color":"yellow"});
//console.log(jQuery(this).find(".rt:eq(1)").html());
}
if (selfPer > (perAcre * 1.5)){
jQuery(this).find(".ct").css({"color":"red"});
}else if (selfPer > perAcre){
jQuery(this).find(".ct").css({"color":"yellow"});
}

if (((selfLand > land) && (selfRank > rank)) || ((selfLand < land) && (selfRank < rank))){
jQuery(this).find(".rt:first").css({"color":"red"});
}
});
}

if (currentPage.indexOf("research") > 0){
var tpt = Math.round(jQuery(".TPT").html().replace(/,/g, ''));
var curVal = 0.0;
var newVal = 0.0;
var tCount = 0;

jQuery(".turntable tr:nth-child(13)").find("td").append("<div id='tSpent' style='display:inline'></div>");
jQuery(".turntable tr.ct").each(function(){
if (jQuery(this).find("td input[value='Research Technology']").length == 0){
jQuery(this).find("td:nth-child(1)").click(function(evt){
curVal = Math.round(jQuery(this).closest("tr").find("input:text").val());
if(evt.ctrlKey){
mult = 5;
}else if(evt.altKey){
mult = 0.5;
}else{
mult = 1;
}
newVal = Math.floor(curVal + (tpt * mult));
tCount = tCount + mult;
jQuery(this).closest("tr").find("input:text").val(newVal);

jQuery("#tSpent").html(" ("+ tCount + ")");
});
}
});
}

if (currentPage.indexOf("build") > 0){
var bpt = Math.round(jQuery(".BPT").html());
var curVal = 0.0;
var newVal = 0.0;
var tCount = 0;

jQuery(".contenttable tr:nth-child(11)").find("td").append("<div id='tSpent' style='display:inline'></div>");
jQuery(".contenttable tr.rt").each(function(){
if (jQuery(this).find("td input[value='Construct Buildings']").length == 0){
jQuery(this).find("td:nth-child(1)").click(function(evt){
curVal = Math.round(jQuery(this).closest("tr").find("input:text").val());

if(evt.ctrlKey){
mult = 5;
}else if(evt.altKey){
mult = 0.5;
}else{
mult = 1;
}
newVal = Math.floor(curVal + (bpt * mult));
tCount = tCount + mult;
jQuery(this).closest("tr").find("input:text").val(newVal);

jQuery("#tSpent").html(" ("+ tCount + ")");
});
}
});

var totLand = 0;
jQuery(jQuery(".contenttable td.lt").next("td")).each(function(){
totLand += parseInt(jQuery(this).text());
});
totLand += parseInt(jQuery(".contenttable td:contains('Unused Land Area')").next("td").text().replace(" Acres","").replace(",","").replace(",",""));

jQuery(".contenttable").find("tr").each(function(i){
if (jQuery(this).find("th").length < 1){
jQuery(this).append("<td class='b"+ i +"'></td>");
}else{
jQuery(this).append("<th>"+ totLand +"</th>");
}
});

jQuery(jQuery(".contenttable td.lt, .contenttable td:contains('Unused Land Area')").next("td")).each(function(i){
if(parseInt(jQuery(this).text().replace(" Acres","").replace(",","").replace(",","")) > 0){
percB = (parseInt(jQuery(this).text().replace(" Acres","").replace(",","").replace(",","")) / totLand) * 100;
percB = percB.toFixed(2);
jQuery(".b"+(i+1)).text(percB + "%");
}
});

}



Let me know if you have installed it and what you think of it, or if you have any bugs

Edited By: TheMafia on Aug 2nd 2022, 16:11:58
Back To Thread
See Original Post
See Subsequent Edit