// ==UserScript==
// @name Politics and War Helper
// @description Adds useful functions to the Game Politics and War
// @include https://politicsandwar.com/*
// @version 0.5.9
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @namespace https://gf.qytechs.cn/users/3941
// ==/UserScript==
//Save nation name to variable
if(GM_getValue("nationName", 0) == 0){
getNationName();
}
//Logout to reset nationName
if(jQuery(document).find("li:contains('Login')").length){
GM_deleteValue("nationName");
}
var pathAll = window.location.pathname.split('/');
path = pathAll[2];
var prices = [];
var resources = ["coal","oil","bauxite","iron","lead","uranium","food","gasoline","aluminum","steel","munitions","credits"];
var resCount = 0;
if(typeof jQuery('select[name="resource1"]').val() != 'undefined' && jQuery('select[name="resource1"]').val().length > 0){
var resource1 = jQuery('select[name="resource1"]').val();
var buysell = jQuery('select[name="buysell"]').val();
var id = jQuery('input[name="id"]').val();
var display = jQuery('input[name="display"]').val();
var ob = jQuery('select[name="ob"]').val();
var maximum = jQuery('input[name="maximum"]').val();
var minimum = jQuery('input[name="minimum"]').val();
var od;
if(buysell == "sell"){
buysell = "buy";
od = "DESC";
}else{
buysell = "sell";
od = "ASC";
}
jQuery('div[id="rightcolumn"] form:eq(0)').after('<form action="/index.php" method="get"><input type="hidden" name ="id" value="'+id+'"><input type="hidden" name ="display" value="'+display+'"><input type="hidden" name ="resource1" value="'+resource1+'"><input type="hidden" name ="buysell" value="'+buysell+'"><input type="hidden" name ="ob" value="'+ob+'"><input type="hidden" name ="od" value="'+od+'"><input type="hidden" name ="maximum" value="'+maximum+'"><input type="hidden" name ="minimum" value="'+minimum+'"><p style="text-align:center;"><input type="submit" value="Switch Buy/Sell"></p></form>');
}
if(path == "manager" && pathAll[3] == "n="+GM_getValue("nationName")){
var impImg = ["https://politicsandwar.com/img/cities/coalpower.png","https://politicsandwar.com/img/cities/oilpower.png","https://politicsandwar.com/img/cities/nuclearpower.png","https://politicsandwar.com/img/cities/windpower.png","https://politicsandwar.com/img/cities/coalmine.png","https://politicsandwar.com/img/cities/ironmine.png","https://politicsandwar.com/img/cities/uraniummine.png","https://politicsandwar.com/img/cities/farm.png","https://politicsandwar.com/img/cities/oilrefinery.png","https://politicsandwar.com/img/cities/steelmill.png","https://politicsandwar.com/img/cities/aluminumrefinery.png","https://politicsandwar.com/img/cities/munitionsfactory.png","https://politicsandwar.com/img/cities/policestation.png","https://politicsandwar.com/img/cities/hospital.png","https://politicsandwar.com/img/cities/recyclingcenter.png","https://politicsandwar.com/img/cities/subway.png","https://politicsandwar.com/img/cities/supermarket.png","https://politicsandwar.com/img/cities/bank.png","https://politicsandwar.com/img/cities/mall.png","https://politicsandwar.com/img/cities/stadium.png","https://politicsandwar.com/img/cities/barracks.png","https://politicsandwar.com/img/cities/factory.png","https://politicsandwar.com/img/cities/airforcebase.png","https://politicsandwar.com/img/cities/drydock.png"];
var impDesc = ['<p class="">Coal power is an inexpensive but dirty way to power your city. Coal plants cost $5,000 to build.</p><p class="">Coal power plants can provide power for up to 500 infrastructure levels. They use 1.2 tons of coal a day (0.1/turn) per 100 infrastructure. Operational costs are $1200 a day ($100/turn).</p><p class="">Coal plants add 8 points to your pollution index.</p>','<p class="">Oil power is cleaner than coal power but more expensive. Oil plants cost $7,000 to build.</p><p class="">Oil power plants can provide power for up to 500 infrastructure levels. They use 1.2 tons of oil a day (0.1/turn) per 100 infrastructure. Operational costs are $1800 a day. ($150/turn)</p><p>Oil plants add 6 points to your pollution index.</p>','<p class="">Nuclear power is very expensive but provides a lot of power and is clean. Nuclear plants cost $500,000 and <img src="https://politicsandwar.com/img/resources/steel.png" class="">100 to build.</p><p>They use 1.2 tons a day (0.1/turn) of uranium per 1,000 infrastructure and can power up to 2,000 infrastructure. Operational costs are $10,500 a day ($875/turn).</p><p>Nuclear power plants do not affect your pollution index.</p>','<p class="">Wind power is expensive and does not provide much power but is very clean. Wind plants cost $30,000 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">25 to build.</p><p>Wind power plants can provide power for up to 250 infrastructure levels. They do not require resources to operate. Operational costs are $500 a day ($42/turn).</p><p>Wind power plants do not affect your pollution index.</p>','<p class="">Coal mines allow you to harvest coal for energy use and trade. Coal mines cost $1,000 to build.</p><p class="">Coal mines provide 0.5 tons of coal per turn or 6 tons of coal per day. Operational costs are $400 per day ($34/turn). You can have up to 6 coal mines per city.</p><p class="">Each coal mine adds 6 points to your pollution index.</p>','<p class="">Iron mines allow you to harvest iron which is refined into Steel. Steel can be used for a variety of things, namely naval ships and structures. Iron mines cost $9,500 to build.</p><p class="">Iron mines provide 0.5 tons of iron per turn or 6 tons of iron per day. Operational costs are $1,600 per day ($134/turn). You can have up to 3 iron mines per city.</p><p class="">Each iron mine adds 6 points to your pollution index.</p>','<p class="">Uranium mines allow you to harvest uranium for energy use, trade, and nuclear weapons. Uranium mines cost $25,000 to build.</p><p class="">Uranium mines provide 0.25 tons of uranium per turn or 3 tons of uranium per day. Operational costs are $5,000 per day ($417/turn). You can have up to 2 uranium mines per city.</p><p class="">Each uranium mine adds 10 points to your pollution index.</p>','<p class="">Farms allow you to produce food for your ever growing population. Farms cost $1,000 to build.</p><p class="">Farms provide food equivalent to your (Land Area / 300) tons of food per turn or (Land Area / 25) tons of food per day. Operational costs are $300 per day ($25/turn). You can have up to 8 farms per city.</p><p>Each farm adds 1 point to your pollution index.</p>','<p>Oil Refineries turn oil into gasoline. They can turn 3 tons of oil into 6 tons of gasoline daily (0.5/turn). Oil Refineries cost $45,000 to build.</p><p>Operational costs are $4,000 per day ($334/turn). You can have up to 3 oil refineries per city.</p><p>Each oil refinery adds 16 points to your pollution index.</p>','<p>Steel Mills turn iron into steel. They can turn 3 tons of iron and coal into 9 tons of steel daily (0.75/turn). Steel Mills cost $45,000 to build.</p><p>Operational costs are $4,000 per day ($334/turn). You can have up to 3 steel mills per city.</p><p>Each steel mill adds 20 points to your pollution index.</p>','<p>Aluminum Refineries turn bauxite into aluminum. They can turn 3 tons of bauxite into 9 tons of aluminum daily (0.75/turn). Aluminum Refineries cost $30,000 to build.</p><p>Operational costs are $2,500 per day ($209/turn). You can have up to 3 aluminum refineries per city.</p><p>Each aluminum refinery adds 20 points to your pollution index.</p>','<p>Munitions Factories turn lead into munitions. They can turn 6 tons of lead into 18 tons of munitions daily (1.5/turn). Munitions factories cost $35,000 to build.</p><p>Operational costs are $3,500 per day ($292/turn). You can have up to 3 munitions factories per city.</p><p>Each munitions factory adds 16 points to your pollution index.</p>','<p>Police Stations reduce crime by 2.5%. Police Stations cost $75,000 and <img src="https://politicsandwar.com/img/resources/steel.png" class="">20 to build.</p><p>Operational costs are $750 per day ($63/turn). You can have up to 5 police stations per city.</p><p>Police stations add 1 point to your pollution index.</p>','<p>Hospitals reduce disease by 2.5%. Hospitals cost $100,000 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">25 to build.</p><p>Operational costs are $1,000 per day ($84/turn). You can have up to 5 hospitals per city.</p><p>Each hospital adds 4 points to your pollution index.</p>','<p>Recycling centers reduce the pollution index by 70 in this city. Recycling centers cost $125,000 to build.</p><p>Operational costs are $2,500 per day ($209/turn). You can have up to 3 recycling centers per city.</p><p>Each recycling center removes 70 points from your pollution index.</p>','<p>Subways increase the commerce rate by 7% and reduce the pollution index by 45 in this city. Subways cost $250,000, <img src="https://politicsandwar.com/img/resources/steel.png" class="">50 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">25 to build.</p><p>Operational costs are $3,250 per day ($271/turn). You can have up to 1 subway per city.</p><p>Each subway removes 45 points from your pollution index.</p>','<p>Supermarkets increase commerce by 4%. Supermarkets cost $5,000 to build.</p><p>Operational costs are $600 per day ($50/turn). You can have up to 5 supermarkets per city.</p><p>Supermarkets do not affect your pollution index.</p>','<p>Banks increase commerce by 7%. Banks cost $15,000, <img src="https://politicsandwar.com/img/resources/steel.png" class="">5 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">10 to build.</p><p>Operational costs are $1,800 per day ($150/turn). You can have up to 4 banks per city.</p><p>Banks do not affect your pollution index.</p>','<p>Shopping malls increase commerce by 12%. Shopping malls cost $45,000, <img src="https://politicsandwar.com/img/resources/steel.png" class="">20 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">25 to build.</p><p>Operational costs are $5,400 per day ($450/turn). You can have up to 3 shopping malls per city.</p><p>Each shopping mall adds 2 points to your pollution index.</p>','<p>Stadiums increase the commerce by 18%. Stadiums cost $100,000, <img src="https://politicsandwar.com/img/resources/steel.png" class="">40 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">50 to build.</p><p>Operational costs are $12,150 per day ($1013/turn). You can have up to 2 stadiums per city.</p><p>Each stadium adds 5 points to your pollution index.</p>','<p>Barracks allow you to train infantry. Barracks cost $3,000 to build.</p><p>Barracks house soldiers and increase the maximum amount you can have enlisted. Each barracks houses 3,000 soldiers. Each soldier costs $1.25 per day in peacetime, or $1.88 per day in wartime. You can have 5 barracks per city.</p>','<p>Factories allow you to manufacture tanks. Factories cost $15,000 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">5 to build.</p><p>Factories allow you to manufacture up to 50 new tanks a day at a maximum of 250 tanks per factory. Each tank costs $50 per day in peacetime and $75 per day in wartime. In battles tanks use <img src="https://politicsandwar.com/img/resources/gasoline.png" class="">1 per 100 tanks and <img src="https://politicsandwar.com/img/resources/munitions.png" class="">1 per 100 tanks. You can have 5 factories per city.</p>','<p>Air Force Bases allow you to manufacture aircraft. Air Force Bases cost $100,000 and <img src="https://politicsandwar.com/img/resources/steel.png" class="">10 to build.</p><p>Air Force Bases allow you to manufacture up to 3 new aircraft a day at a maximum of 18 aircraft per air force base. Each aircraft costs $500 per day in peacetime and $750 per day in wartime. In battles aircraft use <img src="https://politicsandwar.com/img/resources/gasoline.png" class="">1 per 4 aircraft and <img src="https://politicsandwar.com/img/resources/munitions.png" class="">1 per 4 aircraft. You can have 5 air force bases per city.</p>','<p>Drydocks allow you to manufacture navy ships. Drydocks cost $250,000 and <img src="https://politicsandwar.com/img/resources/aluminum.png" class="">20 to build.</p><p>Drydocks allow you to manufacture up to 1 new naval ship per day at a maximum of 5 ships per drydock. Each ship costs $3,750 per day in peacetime and $5,625 per day in wartime. In battles ships use <img src="https://politicsandwar.com/img/resources/gasoline.png" class="">2 per ship and <img src="https://politicsandwar.com/img/resources/munitions.png" class="">3 per ship. You can have 3 drydocks per city.</p>'];
var cityLink = [];
if(GM_getValue("citmanagerError", 0) != 0){
jQuery(document).find("div[class='columnheader']").eq(0).after(GM_getValue("citmanagerError"));
GM_deleteValue("citmanagerError");
}
jQuery(document).find("div[id='footer']").append('<iframe id="pwhFrame" frameBorder="0" style="width:1px; height:1px;"></iframe>');
var tooltipCount = 0;
jQuery(document).find("tbody:eq(0)").find("tr:eq(9)").nextAll().each(function(){
jQuery(this).find("td:eq(0)").find("b").attr("class", "cooltip").append('<span class="spantip"><img src="'+impImg[tooltipCount]+'" class="img-responsive" style="float:right;" />'+impDesc[tooltipCount]+'</span>');
tooltipCount++;
});
jQuery(document).find("tbody:eq(0)").find("tr:eq(0)").find("th:eq(1)").nextAll().each(function(){
var cityUrl = jQuery(this).find("a").attr('href').split("/");
cityLink.push(cityUrl[4]);
});
var submitIndex = 2;
jQuery(document).find("tbody:eq(0)").find("tr:eq(9)").nextAll().each(function(){
var cityIndex = 0;
jQuery(this).find("td:eq(1)").nextAll().each(function(){
jQuery(this).wrapInner('<div class="col-md-8" style="padding-top:9%;"></div>');
jQuery(this).append('<div class="col-md-4"><button type="button" class="btn btn-default pwhImprovButton" style="padding: 2px 6px; font-size: 5px;" value="'+cityLink[cityIndex]+':'+submitIndex+':'+'buy"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button><br /><button type="button" class="btn btn-default pwhImprovButton" style="padding: 2px 6px; font-size: 5px;" value="'+cityLink[cityIndex]+':'+(submitIndex+1)+':'+'sell"><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button></div>');
cityIndex++;
});
submitIndex = submitIndex+2;
});
jQuery(document).on("click", ".pwhImprovButton", function() {
var improvButtHash = jQuery(this).val().split(":");
var cityHash = improvButtHash[0];
var submitIndex = improvButtHash[1];
var buttAction = improvButtHash[2];
jQuery.when(setupCityPage(cityHash)).then(function(){
var pwhConfirm = confirm("Are you sure you want to "+buttAction+" this improvment?");
if(pwhConfirm == true){
jQuery("#pwhFrame").contents().find("input[type='submit']").eq(submitIndex).trigger("click");
jQuery("#pwhFrame").load(reloadCityManager);
}
});
});
}
if(path == "revenue" && pathAll[3] != "log"){
//Delete Old Values
for(i = 0; i < resources.length; ++i){
GM_deleteValue("sell"+resources[i]);
GM_deleteValue("buy"+resources[i]);
}
//Calls getPrice on each resource to get top PPU
for(i = 0; i < resources.length; ++i){
getPrice(resources[i]);
getPrice(resources[i], "buy");
}
checkPrices();
jQuery(document).on("change", "#helperLandSelect", function() {
var ppu = GM_getValue("sellfood");
var helperLandSelect = jQuery(this).val();
var profit = ppu*(helperLandSelect/25)-300;
jQuery("#helperLandProfit").text("$"+profit);
GM_setValue("savedLand", helperLandSelect);
});
}
if(path == "military"){
//Creates table of handy military unit information
jQuery("#rightcolumn").append(
'<table class="nationtable" style="margin: 0 auto; width: 100%;"><tbody>'+
'<tr><th>Unit</th><th>Enlist/Manufacture Cost</th><th>Upkeep (Peace/War)</th><th>Operational Costs</th></tr>'+
'<tr><td><a href="/nation/military/soldiers/">Soldiers</a></td><td style="text-align:right;">$2/Soldier</td><td style="text-align:right;">$1.25 <img src="/img/resources/food.png">1/750 / $1.88 <img src="/img/resources/food.png">1/500</td><td style="text-align:right;">Optional 75% Boost - 1 <img src="/img/resources/munitions.png">Munitions per 5,000 soldiers</td></tr>'+
'<tr><td><a href="/nation/military/tanks/">Tanks</a></td><td style="text-align:right;"><img src="/img/resources/steel.png">1 $60</td><td style="text-align:right;">$50 / $75</td><td style="text-align:right;">1 <img src="/img/resources/munitions.png">Munitions and 1 <img src="/img/resources/gasoline.png">Gasoline per 100 tanks</td></tr>'+
'<tr><td><a href="/nation/military/aircraft/">Aircraft</a></td><td style="text-align:right;"><img src="/img/resources/aluminum.png">3 $4000</td><td style="text-align:right;">$500 / $750</td><td style="text-align:right;">1 <img src="/img/resources/gasoline.png">Gasoline and 1 <img src="/img/resources/munitions.png">Munitions per 4 aircraft</td></tr>'+
'<tr><td><a href="/nation/military/navy/">Naval Ships</a></td><td style="text-align:right;"><img src="/img/resources/steel.png">25 $50,000</td><td style="text-align:right;">$3,750 / $5,625</td><td style="text-align:right;">2 <img src="/img/resources/gasoline.png">Gasoline and 3 <img src="/img/resources/munitions.png">Munitions per ship per battle</td></tr>'+
'<tr><td><a href="/nation/military/spies/">Spies</a></td><td style="text-align:right;">$50,000</td><td style="text-align:right;">$2,400</td><td style="text-align:right;">Pay a fee for every operation</td></tr>'+
'<tr><td><a href="/nation/military/missiles/">Missiles</a></td><td style="text-align:right;"><img src="/img/resources/aluminum.png">100 <img src="/img/resources/gasoline.png">75 <img src="/img/resources/munitions.png">75 $150,000</td><td style="text-align:right;">$21,000 / $31,500</td><td style="text-align:right;">None</td></tr>'+
'<tr><td><a href="/nation/military/nukes/">Nuclear Weapons</a></td><td style="text-align:right;"><img src="/img/resources/aluminum.png">750 <img src="/img/resources/gasoline.png">500 <img src="/img/resources/uranium.png">250 $1,750,000</td><td style="text-align:right;">$35,000 / $52,500</td><td style="text-align:right;">None</td></tr>'+
'</tbody></table>'
);
}
//Adds quick links to your cities to the top of the page
getCityUrls();
/*-------------------FUNCTIONS-----------------------------------------------------------*/
//Function to captitalize strings - http://stackoverflow.com/a/4878800
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
//Saves nation name to a variable
function getNationName(){
jQuery.get("https://politicsandwar.com/nation", function(response) {
var data = jQuery.parseHTML(response);
if(jQuery(response).find("li:contains('Login')").length){
GM_deleteValue("nationName");
}else{
var title = jQuery(response).find("th").eq(4).find("a").attr("href").split('=');
GM_setValue("nationName", title[1].trim().replace(/ /g, '%20'));
}
});
}
//Loads city page in invisible iframe to allow buying/selling improvements
function setupCityPage(cityHash){
var deferred = jQuery.Deferred();
jQuery(document).find("iframe[id='pwhFrame']").attr("src",'https://politicsandwar.com/city/'+cityHash).load(deferred.resolve);
return deferred.promise();
}
//reloads page or displays errors
function reloadCityManager(){
if(jQuery("#pwhFrame").contents().find("div[class='alert alert-danger']").length){
GM_setValue("citmanagerError", jQuery("#pwhFrame").contents().find("div[class='alert alert-danger']").wrap("<div>").parent().html());
window.location = window.location.href;
}else{
location.reload();
}
}
//Waits until current prices are loaded then creates tables
function checkPrices(){
if(resCount != resources.length * 2){
setTimeout(checkPrices, 1e3);
}else{
createProfitsTable();
createBuySellTable();
var now = new Date().getTime();
if(GM_getValue("lastUpdate", 0) == 0 || Number(GM_getValue("lastUpdate"))+3.6e+6 < now){
GM_setValue("lastUpdate", now);
GM_xmlhttpRequest({
method: "POST",
url: "http://www.ereptools.tk/paw/pnwhelper.php",
data: "coal="+GM_getValue("sellcoal")+"&oil="+GM_getValue("selloil")+"&bauxite="+GM_getValue("sellbauxite")+"&iron="+GM_getValue("selliron")+"&lead="+GM_getValue("selllead")+"&uranium="+GM_getValue("selluranium")+"&food="+GM_getValue("sellfood")+"&gasoline="+GM_getValue("sellgasoline")+"&aluminum="+GM_getValue("sellaluminum")+"&steel="+GM_getValue("sellsteel")+"&munitions="+GM_getValue("sellmunitions")+"&credits="+GM_getValue("sellcredits"),
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
}
}
}
function createBuySellTable(){
jQuery("tbody").append('<tr><th colspan="3">Buy/Sell Comparison</th></tr>');
jQuery("tbody").append('<tr><th>Lowest Selling Offer</th><th>Highest Buying Offer</th><th>Difference</th></tr>');
for(i = 0; i < resources.length; ++i){
var res = resources[i];
var sell = GM_getValue("sell"+res);
var buy = GM_getValue("buy"+res);
jQuery("tbody").append('<tr><td><img src="/img/resources/'+res+'.png" style="height:16px; width:16px;"> '+toTitleCase(res)+' <p style="text-align:right; margin:0; float:right;"><a href="/index.php?id=26&display=world&resource1='+res+'&buysell=sell&ob=price&od=ASC">$'+sell+'</a></p><td style="text-align:right;"><a href="/index.php?id=26&display=world&resource1='+res+'&buysell=buy&ob=price&od=DESC">$'+buy+'</a></td><td style="text-align:right;">$'+(Number(sell)-Number(buy))+'</td></tr>');
}
}
function createProfitsTable(){
jQuery("tbody").append('<tr><th colspan="3">Profit Table<br /><small>*Profits on manufactured products are based on buying needed resources from the market</small></th></tr>');
jQuery("tbody").append('<tr><th>Resource (ppu)</th><th>Profit</th><th>Start Up Cost</th></tr>');
for(i = 0; i < resources.length; ++i){
var res = resources[i];
var ppu = GM_getValue("sell"+res);
var profit = "";
var startUp = "";
if(res == "food"){
var savedLand = GM_getValue("savedLand", 1000);
profit = ppu*(savedLand/25)-300;
startUp = "$1000";
}
if(res == "gasoline"){
profit = ppu*6-4000-GM_getValue("selloil")*3;
startUp = "$45000";
}
if(res == "oil"){
profit = ppu*9-600;
startUp = "$1500";
}
if(res == "coal"){
profit = ppu*6-400;
startUp = "$1000";
}
if(res == "uranium"){
profit = ppu*3-5000;
startUp = "$25000";
}
if(res == "steel"){
profit = ppu*9-4000-3*(Number(GM_getValue("selliron")) + Number(GM_getValue("sellcoal")));
startUp = "$45000";
}
if(res == "iron"){
profit = ppu*6-1600;
startUp = "$9500";
}
if(res == "munitions"){
profit = ppu*18-3500-6*(GM_getValue("selllead"));
startUp = "$35000";
}
if(res == "lead"){
profit = ppu*9-1500;
startUp = "$7500";
}
if(res == "aluminum"){
profit = ppu*9-2500-3*GM_getValue("sellbauxite");
startUp = "$30000";
}
if(res == "bauxite"){
profit = ppu*6-1600;
startUp = "$9500";
}
if(res != "credits"){
if(res == "food"){
jQuery("tbody").append('<tr><td><img src="/img/resources/'+res+'.png" style="height:16px; width:16px;"> <a href="/index.php?id=26&display=world&resource1='+res+'&buysell=sell&ob=price&od=ASC">'+toTitleCase(res)+'</a> ('+ppu+' ppu) <select id="helperLandSelect" name="helperLandSelect"><option value="1000">1,000 Land</option><option value="1500">1,500 Land</option><option value="2000">2,000 Land</option><option value="2500">2,500 Land</option></select></td><td id="helperLandProfit" style="text-align:right;">$'+profit+'</td><td style="text-align:right;">'+startUp+'</td></tr>');
jQuery("#helperLandSelect").val(savedLand);
}else{
jQuery("tbody").append('<tr><td><img src="/img/resources/'+res+'.png" style="height:16px; width:16px;"> <a href="/index.php?id=26&display=world&resource1='+res+'&buysell=sell&ob=price&od=ASC">'+toTitleCase(res)+'</a> ('+ppu+' ppu)</td><td style="text-align:right;">$'+profit+'</td><td style="text-align:right;">'+startUp+'</td></tr>');
}
}
}
}
//Function loads Market page by resource and gets top PPU
function getPrice(resource,method) {
var sort;
method = typeof method !== 'undefined' ? method : "sell";
if(method == "sell"){
sort = "ASC";
}else{
sort = "DESC";
}
jQuery.get("/index.php?id=26&display=world&resource1="+resource+"&buysell="+method+"&ob=price&od="+sort, function(response) {
var data = jQuery.parseHTML(response);
var price = jQuery(data).find("tr:eq(1)").find("td:eq(5)").text().replace(/,/g, '').split(" ");
GM_setValue(method+resource, price[1]);
resCount++;
});
}
//Adds quick links to your cities to the top of the page
function getCityUrls() {
jQuery("#rightcolumn").prepend('<div class="columnheader" style="font-size: small; line-height: inherit;"><a href="https://politicsandwar.com/city/manager/n='+GM_getValue("nationName")+'" style="color:#e7e7e7;">City Manager</a></div><center style="margin-bottom: 10px; font-size: small;"></center>');
jQuery.get("/nation/", function(response) {
var data = jQuery.parseHTML(response);
var urls = jQuery(data).find("tbody:eq(1)").find("tr:eq(2)").nextUntil("tr[class='hidden-xs']").each(function(){
if(jQuery("td:eq(0)", this).text() != "Show More/Less"){
jQuery("#rightcolumn center").prepend(' <a href="'+jQuery("a",this).attr("href")+'#improvements">'+jQuery("td:eq(0)", this).text()+'</a> ');
}
});
});
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('b.cooltip{outline:none}b.cooltip strong{line-height:30px}b.cooltip:hover{text-decoration:none}b.cooltip span{z-index:10;display:none;padding:14px 20px;margin-top:-80px;margin-right:-200px;width:60vw;line-height:16px}b.cooltip:hover span{display:inline;position:absolute;border:2px solid #FFF;color:#EEE;background:#333 url(cssttp/css-tooltip-gradient-bg.png) repeat-x 0 0}.callout{z-index:20;position:absolute;border:0;top:-14px;left:120px}b.cooltip span{border-radius:2px;box-shadow:0px 0px 8px 4px #666}');