Verified:

TheMafia Game profile

Member
63

May 20th 2015, 4:36:15

What it does:
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

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 it does (Screen shot link):
Main: http://tcpm.mrlazyinc.com/..._monkey_script_scores.PNG
Works on leader boards too: http://tcpm.mrlazyinc.com/...monkey_script_leaders.PNG

What you need to do:
Lets say you use tamperMonkey and chrome.
-Open the dashboard for tampermonkey, start a new script and copy the script from below into the new page.
-Enter your player number into the line that says "var self = "#69";" (my number is '#69') the pound sign is required.

Script:

// ==UserScript==
// @name EarthEmpires
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match *://http://www.earthempires.com/*/scores
// @match *://http://www.earthempires.com/*/ranks
// @match *://http://www.earthempires.com/*/market*
// @grant none
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
var currentPage = window.location.href;

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 = "";
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();
console.log(jQuery(this).closest("tr").children("td:nth-child(3)").find("input").val());
cashAmount = "$" + (Math.round(jQuery(this).closest("tr").children("td:nth-child(3)").find("input").val()) * Math.round(jQuery(this).html().replace(",", "").replace(",", "").replace("$", ""))).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).closest("tr").children("td:nth-child(7)").find("input").val();
});;
});
}

if (currentPage.indexOf("scores") > 0 || currentPage.indexOf("ranks") > 0){
var land = 0;
var networth = 0;
var perAcre = 0;
var rank = 0;
var selfPer = 0;
var selfLand = 0;
var selfNet = 0;
var self = "#69";
var selfRank = 0;

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());
console.log(selfRank);
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){
jQuery(this).find(".ct").css({"color":"yellow"});
}

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



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

Edited By: TheMafia on May 25th 2015, 13:56:17. Reason: New Version update (v2) - May 25
Back To Thread
See Original Post
See Subsequent Edit