nwolf / eRepublik Stuff++

// ==UserScript==
// @name		eRepublik Stuff++
// @version		2.7.17
// @include		*www.erepublik.com*
// @grant		none
// @grant		GM_info
// ==/UserScript==
function ಠ_ಠ(){function t(t){V("head").append("<style>"+t+"</style>")}function e(t){return(""+t).replace(/\B(?=(\d{3})+(?!\d))/g,",")}function i(){t("#NoKills{cursor:default;font:bold 11px arial;float:left;width:145px;margin:0 3px}#NoKills strong{color:#666}#NoKills span{color:#3c8fa7;float:right}"),V("#NoKills").remove(),V("#eRS_settings").before('<div id="NoKills" title="Click to reset stats"><strong>Kills today:</strong><span>'+e(P.stats[0])+"</span><br><strong>Hits:</strong><span>"+e(P.stats[1])+"</span><br><strong>Damage:</strong><span>"+e(P.stats[2])+"</span></div>"),V("#NoKills").tipsy({gravity:"e"}).click(function(){V(".tipsy").hide(),f()})}function a(){setTimeout(a,1e3),V("#maxRecover").remove(),V("#current_health").after('<strong id="maxRecover" style="text-align:right;margin-right:5px;width:98%;background:none">'+food_remaining+"</strong>")}function n(){function t(t){return 10>t?"0"+t:t}setTimeout(n,1e3),V("#full_energy").remove()
var e=Math.max(360*Math.ceil((reset_health_to_recover-food_remaining)/globalNS.userInfo.energyPerInterval)-360+60*parseInt(V("#foodResetHours").text()),0)
V("#current_health").before('<strong id="full_energy" style="text-align:left;left:'+(L?5:15)+'px;background:none">'+t(parseInt(e/3600))+":"+t(parseInt(e%3600/60))+"</strong>").css("padding-left",L?"10px":0)}function o(){V.get("/"+j+"/economy/inventory",function(i){var a=i.replace(/src=/g,"tmpsrc=")
if(P.showStorageInv||(t("#sideInventory{position:absolute;background:#FFF;display:none}#sideInventory img,#sideInventory span{float:left;clear:both}#sideInventory img{width:39px;height:39px;background:linear-gradient(#EEF1EC,#D5DECF)}#sideInventory span{font:bold 10px arial;color:#578B4D;background:linear-gradient(#BEE698,#98D780);width:39px;text-align:center;cursor:default}.col{line-height:19px}"),V("body").prepend('<div id="sideInventory"></div>'),V(".item_mask ul li,.bazooka .item",a).each(function(){if(0!==+V("strong",this).text()){var t=V("strong",this).attr("id")?V("strong",this).attr("id").split("stock_")[1]:"",e=(V("#product_details_"+t+" .attributes",a).html()||"")+(V("#product_details_"+t+" .extra",a).html()||"")
V(this).parent().hasClass("bazooka")&&V(".b_parts li",a).each(function(){e+=V(this).attr("title")+': <span class="col defense">'+V("strong",this).text()+"</span></br>"}),V("#sideInventory").append('<img title="'+e.replace(/"/g,"'")+'"'+F(V("img",this).attr("tmpsrc").split("/images/")[1])+"><span>"+(V(".timer",this).length?parseInt(V(".timer",this).attr("data-duration")/3600)+"h":V("strong",this).text())+"</span>")}}),V("#sideInventory img").tipsy({gravity:"w",html:!0}).parent().fadeIn(500)),!P.storageCapacity){var n=V(".area.storage h4:first strong",a).text().replace(/[,()]/g,"").split("/")
V(".currency_amount").after('<div id="storageCapacity" style="float:left;height:24px;color:#585858;font-size:11px;cursor:default;display:none"><img style="float:left;margin:0 6px 0 2px;width:22px;height:16px"'+F("modules/manager/tab_storage.png")+"><strong>"+e(n[0])+" / "+e(n[1])+'</strong><br><span style="font-size:10px;margin:0">Free: '+e(n[1]-n[0])+"</span></div>").siblings("#storageCapacity").slideDown()}})}function r(){setTimeout(r,L&&globalNS.userInfo.wellness+food_remaining>reset_health_to_recover?15e3:3e3),"AUTOBOT ON"==V("#AutoBotSwitch").text()||!P.lvlUpNoRecovery&&globalNS.userInfo.wellness+food_remaining>10*(V("#experienceTooltip strong:eq(2)").text()-V("#experienceTooltip strong:eq(1)").text())||globalNS.userInfo.wellness>=reset_health_to_recover||food_remaining<smallestFood.use||V.getJSON("/"+j+"/main/eat?format=json&_token="+SERVER_DATA.csrfToken+"&buttonColor=blue",function(t){energy.processResponse(t)})}function s(){t(".eRS_quickMarket{display:none;position:relative;top:-62px}.eRS_quickMarket img{width:18px;height:20px;vertical-align:middle;margin-bottom:2px}#menu4 ul li:nth-child(1):hover > .eRS_quickMarket{display:block}")
for(var e=["","","",""],i='<li><a href="/'+j+"/economy/market/"+U,a='<div class="eRS_quickMarket" style="',n=1;4>=n;n++)for(var o=1;8>=o;o++)1==n&&(e[0]+=8>o?i+"/1/"+o+'"><img'+F("icons/industry/"+n+"/q"+o+".png")+"> Food Q"+o+"</li>":i+'/7/1"><img'+F("icons/industry/7/default.png")+"> Food Raw</li>"),2==n&&(e[1]+=8>o?i+"/2/"+o+'"><img'+F("icons/industry/"+n+"/q"+o+".png")+"> Weapon Q"+o+"</li>":i+'/12/1"><img'+F("icons/industry/12/default.png")+"> Weapon Raw</li>"),3==n&&5>=o&&(e[2]+=i+"/3/"+o+'"><img'+F("icons/industry/"+n+"/q"+o+".png")+"> Ticket Q"+o+"</li>"),4==n&&(e[3]+=8>o?i+"/4/"+o+'"><img'+F("icons/industry/"+n+"/q"+o+".png")+"> House Q"+o+"</li>":i+'/17/1"><img'+F("icons/industry/17/default.png")+"> House Raw</li>")
V("#menu4 ul li:eq(0)").append(a+'right:401px"><ul>'+e[0]+"</ul></div>"+a+'right:264px"><ul>'+e[1]+"</ul></div>"+a+'left:138px"><ul>'+e[2]+"</ul></div>"+a+'"><ul>'+e[3]+"</ul></div>")}function l(){function e(t){t<i.length&&V.post(update_salary_url,i[t],function(a){var n=V("#old_salary_"+i[t].employeeId).parent().parent()
a.status?(V("#old_salary_"+i[t].employeeId+",#salary_value_"+i[t].employeeId).val(a.result.salary),V("#current_salary_"+i[t].employeeId).html(a.result.salary+" "+J),n.append('<div class="notice_holder"><strong>'+a.result.message+"</strong></div>"),setTimeout(function(){V(".notice_holder",n).remove()},4e3),setTimeout(recalculateDues,50)):n.append('<div class="error_holder"><strong>'+a.message+'</strong><a href="javascript:;"></a></div>').click(function(){V(".error_holder",n).remove()}),setTimeout(e,3e3,t+1)})}t("#changeAll{cursor:pointer;background:#83B70B;border:1px;color:#fff;font:bold 11px arial;height:24px}#changeAll:hover{background:#FB7E3D}"),V(".area h4").append('<div style="float:right"><input type="text" style="margin:0 5px;width:40px;text-align:right" class="field" id="eRS_same_all"><button id="changeAll">Lower for All</button></div>')
var i=[]
V.get("/"+j+"/economy/job-market/"+U,function(t){V("#eRS_same_all,#job_salary_value").val(parseFloat(V("strong,sup",V(".jm_salary:eq(1)",t.replace(/src=/g,"tmpsrc="))).text())),V("#changeAll").click(function(){V(".list_group .employee_salary.c3").each(function(){var t=V(".old_salary_value",this).attr("id").split("_")[2],e=V("#eRS_same_all").val().replace(/,/g,".")
e<V("#old_salary_"+t,this).val()&&i.push({action_type:"update_salary",employeeId:t,salary:e,_token:V("#_token").val()})}),e(0)})}),V(".bottom_details").css("cssText","position:sticky;bottom:0"),V(".list_group").css("box-shadow","none"),V("#edit_mode").after('<a id="SortButton" class="blue_plastic"><span style="line-height:30px"></span></a>'),V("#SortButton").click(function(){var t=[]
V(".current_salary").each(function(){t.push({wage:V(this).text().split(" ")[0],row:V(this).parent().parent()})}),"ASC"!=V("#SortButton span").text()?(V("#SortButton span").text("ASC"),t.sort(function(t,e){return t.wage-e.wage})):(V("#SortButton span").text("DESC"),t.reverse())
for(var e=0;e<t.length;e++)V(".list_group").append(t[e].row)}).click()}function c(){var t=location.href.split("/")
if(!(t[7]>4||-1!=t[8].indexOf("?"))){var e=V(".solid.durability strong:eq(0)").text(),i="HP"
1==t[7]&&(e=7!=t[8]?2*t[8]:20),2==t[7]&&(i="Hit"),3==t[7]&&(i="Zone",e=t[8]),4==t[7]&&(e=V(".solid.health").text()),V("#marketplace thead .m_provider").after('<th style="width:110px">Cost Per '+i+"</th>"),V("#marketplace .price_sorted tr").each(function(){var t=parseFloat(V(".m_price",this).text())/e
t=t.toFixed(.1>=t?4:2).split("."),V(".m_provider",this).after('<td class="stprice"><strong>'+t[0]+"</strong><sup>."+t[1]+"<strong> "+J+"/"+i+"</strong></sup></td>")})}}function p(){V(".sell_selector .industry_quality_selector").click(function(){var t=Math.max(V(this).attr("quality"),1),e=V(this).attr("industry")
V("#sell_amount").val(Math.min(itemAmounts[e][t]-(itemPartials[e]?!!itemPartials[e][t]:0),99999))
var i=V("img",this).attr("src").split("/industry/")[1],a=0
V('tr[id^="offer_"]:visible .offer_image').each(function(){V(this).attr("src").split("/industry/")[1]==i&&(a=V(this).parent().parent().find(".offer_price strong").text().replace(/,/g,""),setTimeout(function(){V("#sell_price").val(a)},0))}),a||(setTimeout(function(){V("#sell_price").val(0)},0),V.get("/"+j+"/economy/market/"+U+"/"+e+"/"+t,function(t){V("#sell_price").val(parseFloat(t.split('m_price stprice"')[1].split("<strong>")[1].split("<strong>")[0].replace("</strong><sup>","")))}))}),V(document).ajaxSuccess(function(t,e,i){i.url.match(/postMarketOffer/)&&V("#sell_amount").val(Math.min(itemAmounts[i.data.split("industryId=")[1].split("&")[0]][i.data.split("customization=")[1].split("&")[0]],99999))})}function d(){V("#back_to_battle").click(function(){P.stats[0]++,P.stats[2]+=+V(".award_damage strong").text(),localStorage.setItem("eRS",JSON.stringify(P))})}function g(){function t(){V("button[data-currency=GOLD]").each(function(){var t=V(this).attr("data-price"),i=Math.min(V(this).attr("data-max"),10,Math.floor(100*V("#eCash").val()/t)/100)
V(this).parent().find("input").val(i),V(this).text(V(this).attr("data-i18n")+" "+e(Math.ceil(i*t*100)/100)+" "+J)})}V(document).ajaxSuccess(t),t()}function u(){function i(){V('tr[id^="offer_"]:visible').each(function(){V(".fluid_blue_dark_small,.Net_unit,.Total_net",this).remove()
var t=A(V(".offer_flag",this).attr("src").split("/M/")[1].split(".")[0]),i=V(".offer_image",this).attr("src").split("/industry/")[1].split("/"),a=-1!=i[1].split("_")[0].indexOf("q")?i[1].split("_")[0].replace("q",""):1,o=countryList[t].taxes[i[0]],r=V(".offer_price strong",this).text().replace(/,/g,"")/((100+(+o.value_added_tax+(t!=U?+o.import_tax:0)))/100),s=r*V(".offer_amount",this).text().replace(/,/g,"")
V(".offer_price",this).after('<td class="Net_unit"><strong>'+r.toFixed(4)+"</strong> "+J+'</td><td class="Total_net"><strong>'+e(s.toFixed(2))+"</strong> "+J+'<br><strong style="text-align:right;font-size:11px">'+e((s/n).toFixed(2))+'</strong><span style="font-size:11px"> GOLD</span></td>'),V(".delete_offer",this).after('<a title="Show offer on market" href="/'+j+"/economy/market/"+t+"/"+i[0]+"/"+a+"?sellerId="+H+"&sellerName="+V(".user_identity").text()+"&offerId="+V(this).attr("id").split("_")[1]+"&offerAmount="+V(".offer_amount",this).text().replace(/,/g,"")+"&offerPrice="+V(".offer_price strong",this).text().replace(/,/g,"")+'" target="_blank" class="fluid_blue_dark_small" style="float:right;margin:0 2px 0 7px"><span>O</span></a><a title="Visit market" target="_blank" class="fluid_blue_dark_small" style="float:right" href="/'+j+"/economy/market/"+t+"/"+i[0]+"/"+a+'"><span>M</span></a>')})}t("td:last-child,#Net_unit,.Net_unit,#Total_net,.Total_net,#Total_netF{padding-left:0!important}.Total_net,#Total_netF{padding:15px;text-align:right}.delete_offer{opacity:1!important}")
var a=V(".area.storage h4:first strong").text().replace(/[,()]/g,"").split("/")
V(".area.storage h4:first strong").append(" Free space: "+e(a[1]-a[0])),V("th input").css("width","50px"),V(".offers_product").css("width","70px").next().css("width","80px").next().css("width","120px").next().css("width","60px").next().css("width","132px").find("a").css("cssText","left:10px;margin-right:20px"),V("#sell_offers table").append('<tfoot><tr style="background:#F7FCFF;height:44px"><td colspan="4"><td id="Total_netF"></td><td colspan="2"></td></tr></tfoot>')
var n
V.get("/"+j+"/economy/exchange-market/",function(t){n=t.split("data-price='")[1].split("'")[0],i()}),setInterval(function(){var t=0
V(".Total_net:visible").each(function(){t+=+V("strong:eq(0)",this).text().replace(/,/g,"")}),V("#Total_netF").html("<strong>"+e(t.toFixed(2))+"</strong> "+J+'<br><strong style="font-size:11px">'+e((t/n).toFixed(2))+'</strong><font style="font-size:11px"> GOLD</font>'),V("#Net_unit,#Total_net").remove()
var i=A(V("#market_select img").attr("src").split("/M/")[1].split(".")[0]),a=countryList[i].taxes[V("#sell_product").attr("src").split("/industry/")[1].split("/")[0]],o=(+V("#sell_price").val()||0)/((100+(+a.value_added_tax+(i!=U?+a.import_tax:0)))/100),r=o*(+V("#sell_amount").val()||0)
V(".offers_price").after('<th id="Net_unit"><strong>Net/unit</strong><b>'+o.toFixed(4)+" "+J+'</b></th><th id="Total_net"><strong>Total Net Value</strong><b>'+e(r.toFixed(2))+" "+J+'</b><span style="float:left;height:14px;clear:both;padding:8px 0px 8px 5px;color:#88AFC9;font-size:11px;font-weight:bold">'+e((r/n).toFixed(2))+" GOLD</span></th>")},100),V(document).ajaxSuccess(i)}function h(){t("#eRS_settings{margin:5px 0 -5px;width:100%;display:inline-block;cursor:pointer;background:#83B70B;color:white;font:bold 11px Arial;text-align:center;padding:3px 0px;border-radius:1px}#eRS_settings:hover,#eRS_options a:hover{background:#FB7E3D}#eRS_options a{cursor:pointer;color:white;font-weight:bold;background:#83B70B;padding:5px;margin:20px;border-radius:1px}")
for(var e=[["Battlefield",[["Improve battlefield","battlefield"],["Improve weapon menu","weaponMenu"],["Enable AutoBot","autoBot"],["Show merc, FF, and TP progress","battleMercFF"],["Automatically close wrong side warning","wrongSideNotice"]]],["Common settings",[["Automatic energy recovery","energyRecovery"],["Stop recovery to maximize level-up refill","lvlUpNoRecovery"],["Show remaining time to full energy bar","fullEnergy"],["Show maximum energy to recover","maxEnergy"],["Autorefresh main page every 10 minutes","autoRefresh"],["Display XP needed to level-up","xpLeft"],["Kills, damage and hits on sidebar","showStats"],["Remove external link warning","externalLinks"],["Hide notifications","removeNotifications"],["Epic battle sensor","epicSensor"],["Ignore epic dictatorship battles","ignoreDictatorship"],["Show rankings by damage instead of kills","damageRankings"]]],["Companies",[["Company manager","companyManager"],["Employee manager","employeeManager"],["Add employees link to My places","addEmployeesLink"]]],["Main page",[["Improve feeds","improvedFeeds"]]],["Marketplace",[["Autofill maximum product amount","autofillMarket"],["Product quick links","marketLinks"],["Display cost per use","costPerUse"],["Show the best local/CS price when abroad","localOffer"]]],["Monetary market",[["Autofill maximum gold amount","autofillGold"]]],["Profile",[["Improve profile page","improveProfile"],["Influence calculator","influenceCalculator"]]],["Storage",[["Improve inventory","improveInventory"],["Display storage inventory","showStorageInv"],["Display storage info","storageCapacity"],["Autofill amount and real price","getItemPrice"]]],["Wars page",[["Show dom. points and wall percentages","getPoints"],["Show merc, FF, and TP progress","mercFF"],["Add direct links for each side in RWs","directRWLinks"],["Single row layout","singleRowWars"]]]],i="",a=0;a<e.length;a++){a&&3!=a||(i+='<div style="width:48%;margin:0.5%;float:left;background:#242B27">'),i+='<span style="background:#FB7E3D;color:white;padding:2px;font-weight:bold;display:inline-block;width:98.7%;text-align:center">'+e[a][0]+"</span>"
for(var n=0;n<e[a][1].length;n++)i+='<span style="color:white;padding:2px 5px;display:inline-block;width:100%;font-size:13px">'+e[a][1][n][0]+'<input type="checkbox" style="float:right;margin:2px 10px" id="'+e[a][1][n][1]+'"></span>';(2==a||8==a)&&(i+="</div>")}V("body").append('<div id="eRS_block" style="display:none;z-index:999998;position:fixed;top:0;width:100%;height:100%;background:rgba(0,0,0,0.6)"></div><div id="eRS_options" style="display:none;width:600px;margin:auto;cursor:default;position:fixed;left:'+(V(window).width()-600)/2+'px;z-index:999999"><div style="position:absolute;top:-20px;width:100%;text-align:center"><a href="https://docs.google.com/spreadsheets/d/1nal62cgC7lUmrur6NRzlPVU3uxtE59WGV9-bZcPoIw8/edit" target="_blank">Script Homepage</a><a id="reset" title="Deletes all stored data (settings, stats, caches). If you use other eRepublik scripts utilizing localStorage, their data will be deleted, too.">RESET</a><a href="https://googledrive.com/host/0B3iVfXry1NkpbHRqUmdWTVhtXzQ/eRepublik_Stuff++.user.js">UPDATE</a><a href="/'+j+'/citizen/profile/6365664">Contact / Donate</a><a>Close</a></div>'+i+"</div>"),setTimeout(P.x),V("#eRS_options").css("top",(V(window).height()-V("#eRS_options").height())/2+"px").find("input").each(function(){V(this).prop("checked",!P[V(this).attr("id")])}).change(function(){P[V(this).attr("id")]=!V(this).prop("checked"),localStorage.setItem("eRS",JSON.stringify(P))}),V("#eRS_options a:last,#eRS_block").click(function(){V("#eRS_options,#eRS_block").hide()}),V(".user_finances").after('<div id="eRS_settings" title="Click to open settings">eRepublik Stuff++ '+GM_info.script.version+"</div>"),V("#eRS_settings").tipsy({gravity:"e"}).click(function(){V("#eRS_options,#eRS_block").show()}),V("#reset").click(function(){localStorage.clear(),location.reload()})}function f(){P.stats=[0,0,0],localStorage.setItem("eRS",JSON.stringify(P)),P.showStats||i()}function m(){function t(){V('a[href*="/main/warn/"]').each(function(){var t=V(this).text()
4==location.href.split("/").length||t.match(/www\.|https?:\/\//)?V(this).attr("href",t.match(/https?:\/\//)?t:"http://"+t):V.get(V(this).attr("href"),V.proxy(function(t){V(this).attr("href",t.split('class="content"')[1].split('href="')[1].split('"')[0])},this))})}V(document).ajaxSuccess(t),t()}function _(){V("#xpleft").remove()
var t=V("#experienceTooltip strong:eq(2)").text()-V("#experienceTooltip strong:eq(1)").text()
V(".user_level").append('<div id="xpleft" style="float:right;position:relative;font-size:10px;color:#777;'+(L?'top:-3px;left:23px"><span style="':'top:14px">XP left: <span style="padding:1px')+";background:"+(reset_health_to_recover<=10*t?"#6ebce5":"red")+';color:white;font-weight:bold;border-radius:2px">'+t+"</span></div>"),setTimeout(_,200)}function x(){t("#CompanyManager{float:right}#CompanyManager strong{position:relative;bottom:8px;right:5px;font-size:12px}#CompanyManager span{cursor:pointer;border-radius:3px}#CompanyManager span:hover{opacity:0.5}#CompanyManager img{height:30px}")
for(var e=[0,0,0],i=1;15>=i;i++)e[5>=i?0:10>=i?1:2]+=pageDetails.resources[i].bonus
V(".area h4 a").remove(),V(".area h4").append('<span style="float:left;margin:23px 1px -100%;color:#656565;font:90% bold">Food: <b>+'+e[0]+"%</b> Weapon: <b>+"+e[1]+"%</b> House: <b>+"+e[2]+'%</b></span><div id="CompanyManager"><strong>Work as Manager</strong></div>'),V(".area h4 b").each(function(){V(this).css("color",100==parseInt(V(this).text())?"#83B70B":parseInt(V(this).text())>0?"#FB7E3D":"#D74A4A")}),V(".listing.companies:not(.disabled) .area_pic > img").each(function(){V('#CompanyManager img[src="'+V(this).attr("src")+'"]').length||V("#CompanyManager").append('<span><img src="'+V(this).attr("src")+'" title="'+V('.listing.companies .area_pic > img[src="'+V(this).attr("src")+'"]:eq(0)').attr("title")+'"></span>')}),V("#CompanyManager span").click(function(){V(".listing.companies:not(.disabled) .area_pic > img").parent().parent().find(".owner_work").removeClass("active"),window.pageDetails.recoverable_health.value=food_remaining,V('.listing.companies:not(.disabled) .area_pic > img[src="'+V("img",this).attr("src")+'"]:lt('+Math.floor((globalNS.userInfo.wellness+Math.min(pageDetails.recoverable_health.value,pageDetails.recoverable_health_in_food))/10)+")").parent().parent().find(".owner_work:not(.active)").addClass("active"),V(".listing.companies:not(.disabled)").each(function(t,e){applyCheck(e),warnForCritical()})})}function v(){function e(t){var e=0
return V.each(tickets,function(i,a){a>=t/20&&(e=a)}),e>0?"Q"+e+" ticket":t+"cc"}t(".booster_timer{bottom:90px!important;left:5px!important}#special_items_list,.deploy_bomb{display:block!important}#switch_side{position:absolute;right:37px;background:#83B70B;color:#FFF;padding:3px;font:bold 11px Arial}#switch_side:hover{background:#FB7E3D;cursor:pointer}.top5_list{position:absolute;top:-6px;padding:2px 0;border-radius:2px;background:#242b27;color:white;cursor:default;z-index:31;font:bold 9px Arial,sans-serif}#right_top5{right:0}#campaign_top5{top:60px}#pvp .campaign_details .entry em{opacity:1}#pvp .campaign_details .entry .pdomi_left em{right:5px}#eRSTravel{display:none;position:absolute;top:0;right:115px;background:#4B4B49;border:1px solid #333;color:#FFF;font:11px Arial;padding:1px 4px}"),V("#drop_part,#special_weapons_go,.battle_heroes").remove(),V("#special_items_list").append(V(".addon").children()),V(".deploy_bomb").hide(),V.cookie("collection_full",1,{expires:999,path:"/"}),clearInterval(globalSleepInterval),y(),V(".country_avatar.dictatorship").length||V(".status_bar").append('<a id="switch_side">SWITCH SIDE</a>')
var i=regionsInvolved[rightBattleId]
V("#pvp").append('<select id="eRSTravel"><option>Select region</option></select>')
for(var a in i)i.hasOwnProperty(a)&&V("#eRSTravel").append('<option value="'+i[a].id+'" title="'+e(i[a].travelCost)+'">'+i[a].name+(i[a].current_owner_country_id!=i[a].original_owner_country_id?"*":"")+"</option>")
V("#switch_side").click(function(){SERVER_DATA.isResistance?location.href="http://www.erepublik.com/en/military/battlefield-choose-side/"+SERVER_DATA.battleId+"/"+rightBattleId:V("#eRSTravel").toggle()}),V("#eRSTravel").change(function(){"Select region"!=V("option:selected",this).text()&&(confirm("Are you sure you want to change location?")?V.post("/"+j+"/main/travel/",{battleId:SERVER_DATA.battleId,_token:SERVER_DATA.csrfToken,toCountryId:rightBattleId,inRegionId:V("option:selected",this).attr("value")},function(){location.reload()}):V("#eRSTravel").hide())})}function y(){var i=(((personalStats[SERVER_DATA.zoneId]||{})[leftBattleId]||[]).top_damage||[])[0]||{}
if("undefined"==typeof right_percent||0!==+V("#total_damage strong").text()&&!i.damage)return setTimeout(y,100)
t(".activated{"+(parseFloat(right_percent)<Math.max.apply(null,V("strong[data-bind=mu_treshold]").map(function(t,e){return parseInt(V(e).text())}).get())?"filter:hue-rotate(110deg);-webkit-filter:hue-rotate(110deg)}":"filter:none;-webkit-filter:none}")),V(".top5_list").remove(),V("#battleConsole").append('<div id="left_top5" class="top5_list"></div><div id="right_top5" class="top5_list"></div><div id="campaign_top5" class="top5_list"></div>')
var a=currentStats[SERVER_DATA.zoneId][T()]||{},n=(a[leftBattleId]||{})["top_"+Q],o=(a[rightBattleId]||{})["top_"+Q],r=(overallStats[0][leftBattleId]||{})["top_"+Q],s='<a style="color:#83B70B;margin:0 3px" href="/'+j+"/citizen/profile/",l='</a><span style="float:right;margin:0 3px">'
for(var c in n)n.hasOwnProperty(c)&&V("#left_top5").append(s+n[c].citizen_id+'" target="_blank">'+fightersData[n[c].citizen_id].name+l+e(n[c][Q])+"</span><br>")
for(var p in o)o.hasOwnProperty(p)&&V("#right_top5").append(s+o[p].citizen_id+'" target="_blank">'+fightersData[o[p].citizen_id].name+l+e(o[p][Q])+"</span><br>")
for(var d in r)r.hasOwnProperty(d)&&V("#campaign_top5").append(s+r[d].citizen_id+'" target="_blank">'+fightersData[r[d].citizen_id].name+l+e(r[d][Q])+"</span><br>")
0===+V("#personal_stats q:eq(2)").text()&&(V("#personal_stats").remove(),V("#total_damage").after('<div id="personal_stats" style="cursor:default;text-align:center;position:absolute;top:7px;width:100%;color:#FFE49B;font:bold 11px Arial,sans-serif"><q>'+e(i.kills||0)+"</q> | <q>"+e(i.hits||0)+"</q> | <q>"+e(i.damage||0)+"</q></div>").hide())}function b(){V(document).ajaxSuccess(function(t,a,n){if(n.url.match(/military\/fight-shooot|military\/deploy-bomb/)){var o=JSON.parse(a.responseText)
if(!o.error&&("ENEMY_KILLED"==o.message||"OK"==o.message)){var r=0
n.url.match(/military\/deploy-bomb/)?r=o.bomb.damage:(r=o.user.givenDamage,P.stats[1]+=o.user.earnedXp,V("#personal_stats q:eq(1)").text(e(+V("#personal_stats q:eq(1)").text().replace(/,/g,"")+o.hits)),o.oldEnemy.isNatural&&(r+=Math.floor(.1*r))),P.stats[0]++,P.stats[2]+=r,V("#personal_stats q:eq(0)").text(e(+V("#personal_stats q:eq(0)").text().replace(/,/g,"")+1)),V("#personal_stats q:eq(2)").text(e(+V("#personal_stats q:eq(2)").text().replace(/,/g,"")+r)),localStorage.setItem("eRS",JSON.stringify(P)),P.showStats||i(),W.current+=r,W.done+=r,W.current>=W.next&&(W.next+=1e8,W.done-=1e8),V("#mercenary q").text(Math.min(+V("#mercenary q").text()+1,25)),V("#freedom_fighter q:eq(0)").text(Math.min(+V("#freedom_fighter q:eq(0)").text()+1,75)),V("#true_patriot q").text((W.done/(W.next-W.current+W.done)*100).toFixed(2))}}else n.url.match(/military\/nbp-stats/)&&!P.battlefield&&y()})}function k(){V(".weapon_list").hide(),V("#weapon_btn").click(),V(document).ajaxSuccess(function(t,i,a){a.url.match(/military\/show-weapons/)&&(V(".ammo_stock.low").parents("li").remove(),V(".weapon_list").show()),V("li.active:not(.q-1) a b").text(e(V(".weapon_no").text())),V(".weapon_list").addClass("show").css("bottom","113px").children().css("cssText","border-radius:5px;padding:0"),V(".weapon_link").removeAttr("style")})}function w(){function i(t){"AUTOBOT OFF"==V("#AutoBotSwitch").text()||t!=n||V("#kills").val()<=0&&!V("#allin").is(":checked")||(setTimeout(i,3e3,++n),V.post("/"+j+"/military/fight-shooot/"+SERVER_DATA.battleId,{sideId:SERVER_DATA.countryId,battleId:SERVER_DATA.battleId,_token:SERVER_DATA.csrfToken},function(t){return("UNKNOWN_SIDE"==t.message||"WRONG_SIDE"==t.message)&&(location.href=t.url),"SHOOT_LOCKOUT"==t.message?i(n):"ENEMY_ATTACKED"==t.message||"LOW_HEALTH"==t.message?a(0):(V("#allin").is(":checked")||V("#kills").val(V("#kills").val()-1),V("#rank_min").text(e(t.rank.points)+" Rank Points"),V("#rank_status_gained").css("width",t.rank.percentage+"%"),window.totalPrestigePoints+=t.hits,V("#prestige_value").text(e(window.totalPrestigePoints)),V("#side_bar_currency_account_value").text(e(t.details.currency)),V(".left_player .energy_progress").css("width",t.details.current_energy_ratio+"%"),V(".right_player .player_name").text(t.enemy.name),V(".right_player .energy_progress").css("width",t.enemy.energyRatio+"%"),V(".weapon_no").text(t.user.weaponQuantity),globalNS.updateSideBar(t.details),void a(t.details.wellness))}))}function a(t){setTimeout(function(){return!V("#eatEB").is(":checked")&&!food_remaining&&10>t||V("#kills").val()<=0&&!V("#allin").is(":checked")?V("#AutoBotSwitch").click():!P.lvlUpNoRecovery&&t+food_remaining>=10*(V("#experienceTooltip strong").eq(2).text()-V("#experienceTooltip strong").eq(1).text())||!V("#eatEB").is(":checked")&&!food_remaining||t>=(V("#allin").is(":checked")?50:10)?i(n):(setTimeout(i,3e3,n),void V.getJSON("/"+j+"/main/eat?format=json&_token="+SERVER_DATA.csrfToken+"&buttonColor="+(V("#eatEB").is(":checked")?"orange":"blue"),function(t){i(n),energy.processResponse(t)}))},(!!(H%558)+1)*parseInt("28a",16))}t("#AutoBot{background:#242B27;position:absolute;top:320px;border-radius:3px;color:white;font-size:12px;font-weight:bold;line-height:20px;text-align:center;z-index:31}#AutoBot input{margin:3px}#AutoBotSwitch{cursor:pointer;width:100%;background:#FB7E3D}#AutoBotSwitch:hover{background:#83B70B!important}"),V(".battle_footer").after('<div id="AutoBot"><div style="padding:5px">Kills:<input id="kills" type="text" size="1" value="25" style="text-align:center"><label><input id="allin" type="checkbox">All-in</label></br><label><input id="eatEB" type="checkbox">Eat energy bars</label></div><div id="AutoBotSwitch">AUTOBOT OFF</div></div>')
var n=0
V("#AutoBotSwitch").click(function(){"AUTOBOT OFF"==V(this).text()?(V("#AutoBotSwitch").text("AUTOBOT ON").css("background","#83B70B"),pomelo.disconnect(),i(n)):(V("#AutoBotSwitch").text("AUTOBOT OFF").css("background","#FB7E3D"),connectBattleSocket())}),V("#allin").change(function(){V("#kills").prop("disabled",V(this).is(":checked"))})}function S(){t("#mercenary,#freedom_fighter,#true_patriot{color:#FFF;padding:3px;font:bold 11px Arial;position:absolute;top:0;width:40px}#mercFFdiv{float:right;margin:-10px;position:relative;top:20px;right:10px;z-index:999}#mercFFdiv span{cursor:default;border-radius:1px;padding:3px;color:#4C4C4C;background:"+V("#battle_listing li").css("border-top-color")+";font:bold 11px arial;margin:3px}#mercenary{left:181px;background:#FB7E3D}#freedom_fighter{left:227px;background:#83B70B}#true_patriot{left:"+(V(".resistance_badge").length?273:227)+"px;background:#009CFF}.countyTime > div{text-align:center;position:absolute;width:90px;right:5px;top:-1px}.countyTime div div{display:inline;padding:1px 3px 0;margin:0 2px}"),V(".country_avatar.dictatorship").length||V.get("/"+j+"/citizen/profile/"+H,function(t){var e=t.replace(/src=/g,"tmpsrc="),i=V("#achievment > li:eq(10) .country_list li",e),a=(V('#freedom_fighter_region_list li:not(.completed)[title*=", '+V("#region_name_link").text()+'"] em',e).text()||"0/"+25*(V(".counter:eq(0)",e).text()%3+1)).split("/"),n=V(".citizen_military:eq(0)",e),o=Math.max(+V(".mids",n).css("width").split("%")[0],.001),r=V("strong:last",n).text().replace(/,/g,"").split("/")
W.current=+r[0],W.next=+r[1],W.done=(W.next-W.current)/(100-o)*o
var s=V("#achievment > li:eq(10) span big strong",e).text(),l=25*(V(".counter:eq(0)",e).text()%3+1),c=V("#achievment > li:eq(0) span big:eq(0) strong",e).text(),p=[' title="Mercenary kills"',' title="Freedom Fighter kills"',' title="True Patriot medal progress"']
V(".status_bar").length&&V(".status_bar").append('<div id="mercenary"'+p[0]+"><q>"+V('img[tmpsrc$="/'+V(".country.left_side img").attr("src").split("/").pop()+'"] ~ em',i).text().split("/")[0]+"</q> - "+V('img[tmpsrc$="/'+V(".country.right_side img").attr("src").split("/").pop()+'"] ~ em',i).text().split("/")[0]+"</div>"+(V(".resistance_badge").length?'<div id="freedom_fighter"'+p[1]+"><q>"+Math.min(a[0],75)+"</q> / <q>"+a[1]+"</q></div>":"")+(U==leftBattleId?'<div id="true_patriot"'+p[2]+"><q>"+o.toFixed(2)+"</q>%</div>":"")),V(".resistance_badge").length&&V("#kills").val(a[1]-a[0]>0?a[1]-a[0]:25),V("#battle_listing").before('<div id="mercFFdiv"><span title="'+(c.split("/")[1]-c.split("/")[0])*l+' kills needed">Freedom Fighter '+c+" (x"+l+')</span><span title="'+25*(50-s.split("/")[0])+' kills needed">Mercenary '+s+"</span><span>True Patriot "+o.toFixed(2)+"%</span></div>"),V("#battle_listing ul:not(.victory_listing) li").each(function(){var t=+V('img[tmpsrc$="/'+V(".side_flags:eq(0)",this).attr("src").split("/L/")[1].split(".png")[0]+'.png"] ~ em',i).text().split("/")[0],a=+V('img[tmpsrc$="/'+V(".side_flags:eq(1)",this).attr("src").split("/L/")[1].split(".png")[0]+'.png"] ~ em',i).text().split("/")[0],n=V('#freedom_fighter_region_list li a[href$="'+V(".button_body",this).attr("href")+'"]',e),o=n.parent().parent().find("em").text().split("/")
V(".countyTime",this).append("<div>"+(n.length?"<div"+p[1]+"><span"+(+o[0]<+o[1]?' style="color:#FF6600"':"")+">"+Math.min(o[0],75)+"</span> / "+o[1]+"</div>":"")+"<div"+p[0]+'><span style="color:#'+(t?25>t?"FF6600":"":"DD0000")+'">'+t+'</span> - <span style="color:#'+(a?25>a?"FF6600":"":"DD0000")+'">'+a+"</span></div></div>").find("div div").css("background-color",V(".countyTime",this).css("background-color"))}),V("#mercFFdiv span,#mercenary,#freedom_fighter,#true_patriot,.countyTime div div").tipsy({gravity:"s"})})}function I(){var t=location.href.split("?")[1]
if(!V(".success_message,.error_message").length&&t){var e=t.split("offerId=")[1].split("&")[0],i=t.split("offerAmount=")[1].split("&")[0],a=t.split("offerPrice=")[1]
V(".price_sorted tr:not(:first),.pager").remove(),V(".m_product").attr("id","productId_"+e),V(".m_provider a").attr("href","/"+j+"/citizen/profile/"+t.split("sellerId=")[1].split("&")[0]).text(t.split("sellerName=")[1].split("&")[0]),V(".m_stock:eq(1)").text(i),V(".m_price strong:first").text(a.split(".")[0]),V(".m_price sup").html("."+a.split(".")[1]+" "+J),V(".m_quantity input").attr({id:"amount_"+e,maxlength:"6"}),V(".m_buy a").attr({id:e,"data-max":i,"data-price":a})}}function R(){function i(){var t=V(".citizen_military_box_wide img").attr("src").split("/")[6].split(".")[0].split("_")
return+t.pop()+[{recruit:1,"private":2,corporal:6,sergeant:10,lieutenant:14,captain:18,major:22,commander:26,lt_colonel:30,colonel:34,general:38,field_marshal:42,supreme_marshal:46,national_force:50,world_class_force:54,legendary_force:58,god_of_war:62,titan:66,legendary:70}][0][t.join("_")]}function a(t){V.get("/"+j+"/economy/market/"+U+"/2/"+t,function(e){s[t]=e.split('data-price="')[2].split('"')[0]/(7>t?t:10),s.date=K,localStorage.setItem("eRS_wepprice",JSON.stringify(s)),n()})}function n(){for(var t=V("#InfCalc_hits").val(),a=0;8>a;a++){var n=10*(1+V(".mb_bottom:eq(0)").text().replace(/,/g,"")/400)*(1+i()/5)*(1+(7>a?20*a:200)/100)
V("#InfCalc_NE").is(":checked")&&(n*=1.1),V("#InfCalc_BO").is(":checked")&&!V("#InfCalc_BO2").is(":checked")&&(n*=1.5),V("#InfCalc_BO2").is(":checked")&&(n*=2),V(".citizen_level:eq(0)").text()>100&&(n*=1.1),V("#InfCalc_Q"+a+" span").html((t*n>999999?e((t*n/1e6).toFixed(2))+"M":e(Math.round(t*n)))+"<br>"+e(Math.ceil(10*(o[1]-o[0])/(n/(V("#InfCalc_NE").is(":checked")?1.1:1))))+"<br>"+e(Math.ceil((r[1]-r[0])/n))+"<br>"+(0===a?"-":e((1e6*s[a]/n).toFixed(2))))}}t("#eRS_InfCalc{font-size:11px;color:#666;padding-bottom:0;margin:-10px 0 5px;background:#F7FBF1;border:0}#eRS_InfCalc table{margin:5px}#eRS_InfCalc td{width:11%}#InfCalc_hits{padding:4px;text-align:center;width:35px;font-size:10px;margin:0 20px 0 5px}#eRS_InfCalc label{margin:0 10px}#eRS_InfCalc span{display:inline-block;text-align:right;width:100%}#eRS_InfCalc img{width:40px;height:40px;margin:0 0 0 20px}#InfCalc_BO,#InfCalc_BO2,#InfCalc_NE{vertical-align:middle;margin-left:5px}")
var o=V(".rank_numbers").text().replace(/,/g,"").split("/"),r=V(".stat:eq(0) small:eq(1) strong").length?V(".stat:eq(0) small:eq(1) strong").text().replace(/,/g,"").split("/"):[0,V(".stat:eq(1) small:eq(1) strong").text().replace(/,/g,"").split("/")[1]],s=JSON.parse(localStorage.getItem("eRS_wepprice"))||{0:0}
V(".citizen_military_box_wide").after('<div id="eRS_InfCalc" class="citizen_military"><label>Hits <input type="text" id="InfCalc_hits" value="1"></label><label>Natural Enemy <input type="checkbox" id="InfCalc_NE"></label><label>50% booster <input type="checkbox" id="InfCalc_BO"></label><label>100% booster <input type="checkbox" id="InfCalc_BO2"></label><table><tr><td><span style="text-align:left;margin:44px 0 0"><b>Influence:<br>Rank up:<br>Next TP:<br>Cost cc/M:</b></span></td></tr></table></div>')
for(var l=0;8>l;l++)V("#eRS_InfCalc tr").append('<td id="InfCalc_Q'+l+'"><img'+F("icons/industry/2/q"+(0===l?1:l)+".png")+(0===l?' style="opacity:0.5"':"")+"><span></span></td>"),s[l]&&s.date==K||l>0&&a(l)
n(),V("#InfCalc_hits").keyup(n),V("#InfCalc_NE,#InfCalc_BO,#InfCalc_BO2").change(n)}function F(t){var e=JSON.parse(localStorage.getItem("eRS_imgCache"))||{}
if(t in e&&e[t].length>100)return' src="'+e[t]+'"'
var i=V.now()+""+(1e10*Math.random()).toFixed(0)
V("body").append('<img id="eRS_cache'+i+'" style="display:none" src="/images/'+t+'">')
var a=document.getElementById("eRS_cache"+i),n=document.createElement("canvas"),o=n.getContext("2d")
return n.width=a.width,n.height=a.height,o.drawImage(a,0,0,a.width,a.height),e[t]=n.toDataURL(),localStorage.setItem("eRS_imgCache",JSON.stringify(e)),' src="/images/'+t+'"'}function T(){var t=erepublik.citizen.userLevel
return t>69?4:t>49?3:t>34?2:1}function B(){function i(t){var i=t.is(".dictatorship,.liberation")?255:A(V(".side_flags:eq(0)",t).attr("src").split("/L/")[1].split(".png")[0]),a=A(V(".side_flags:eq(1)",t).attr("src").split("/L/")[1].split(".png")[0])
"Loading data..."==V(".war_versus_img",t).attr("original-title")&&V.getJSON("/"+j+"/military/battle-stats/"+t.attr("id").split("-")[1],function(n){if(n.error)V(".war_versus_img",t).attr("title","Server limit reached. Try again in 10 minutes.")
else{var o=n.stats.current[Object.getOwnPropertyNames(n.stats.current)],r="domination",s="top_"+Q,l=n.division,c=T(),p="",d=""
if(o[c]){if(o[c][i])for(var g in o[c][i][s])o[c][i][s].hasOwnProperty(g)&&(p+=n.fightersData[o[c][i][s][g].citizen_id].name+" <span>"+e(o[c][i][s][g][Q])+"</span><br>")
if(o[c][a])for(var u in o[c][a][s])o[c][a][s].hasOwnProperty(u)&&(d+=n.fightersData[o[c][a][s][u].citizen_id].name+" <span>"+e(o[c][a][s][u][Q])+"</span><br>")}V(".war_versus_img",t).attr("original-title",function(){for(var t="<table><tr><td>Points</td><td>Dom</td><td>Wall</td><td>Status</td><td>Wall</td><td>Dom</td><td>Points</td></tr>",e=1;5>e;e++)t+="<tr "+(e==c?'style="background:#83B70B"':"")+"><td>"+l[i][e].points+"</td><td>"+l[i][e][r]+"</td><td>"+(100-l[r][e]).toFixed(2)+"%</td><td>"+(2===n.battle_zone_situation[e]?"Epic":1===n.battle_zone_situation[e]?"Full":"Cold")+"</td><td>"+l[r][e].toFixed(2)+"%</td><td>"+l[a][e][r]+"</td><td>"+l[a][e].points+"</td></tr>"
return t+'<tr><td colspan="3">'+p+'</td><td></td><td colspan="3">'+d+"</td></tr></table>"}),V(".combat_orders_revamp",t).each(function(){for(var e=V(this).hasClass("right_side"),n=V(this).attr("title").split(">< "),o=1;o<n.length;o++)(100-l[r][c]<n[o].split("%")[0]&&l[i][c][r]<1800&&!e||l[r][c]<n[o].split("%")[0]&&l[a][c][r]<1800&&e)&&V(".countyTime",t).text().indexOf(":")>-1&&V(this).attr("style","filter:hue-rotate(110deg);-webkit-filter:hue-rotate(110deg);"+V(this).attr("style"))})}V(".war_versus_img",t).is(":hover")&&V(".war_versus_img",t).tipsy("show")})}t(".tipsy-inner{max-width:999px!important}.tipsy-inner tr:last-child td{text-align:left;vertical-align:text-top}.tipsy-inner tr:last-child span{float:right;margin:0 0 0 5px}.tipsy-inner td{min-width:30px}"),V(".war_versus_img").attr("original-title","Loading data...").tipsy({gravity:"s",html:!0,opacity:1}),V('#battle_listing ul li[id^="battle-"]').each(function(){V(".combat_orders_revamp",this).length?i(V(this)):V(".war_versus_img",this).mouseover(function(){i(V(this).parent())})})}function E(){t(".RWQuickLink img:hover{transform:scale(1.2,1.2);transition:transform 0.5s}"),V("ul:not(.victory_listing) .resistance_sign").parents("ul li").find(".side_flags").each(function(){V(this).wrap('<a class="RWQuickLink" href="/'+j+"/military/battlefield-choose-side/"+V(this).parents("ul li").attr("id").split("-")[1]+"/"+A(V(this).attr("src").split("/L/")[1].split(".png")[0])+'"></a>')})}function q(){V("a.buyOffer").each(function(){var t=V(this).attr("data-price"),i=Math.min(Math.floor((erepublik.citizen.currencyAmount-1)/t),V(this).attr("data-max"))
V(this).parent().parent().find("input").val(i),V("span",this).text(V(this).attr("data-i18n")+" "+e(Math.ceil(i*t*100)/100)+" "+J)})}function C(){V("#donate_to_friend div").remove(),V(".citizen_avatar").wrap('<a target="_blank" href="http://erpk.static.avatars.s3.amazonaws.com/'+V(".citizen_avatar").attr("style").split("smart/")[1].split(")")[0]+'"></a>')
var t=V(".guerilla_fights.won span").text()/V(".guerilla_fights.lost span").text()||0
V(".hint_info span").html("Win/loss ratio: "+t.toFixed(2)+":1 (Damage bonus: "+(1>t?0:2>t?"+1":"+2")+")")
var e=0
V(".counter").each(function(){e+=+V(this).text()}),V("#career_tab_content").prev().append(" ("+e+")"),V(".citizen_mass_destruction > strong b").css("cssText","display:initial;margin:0 0 0 5px")}function A(t){for(var e in erepublik.info.countries)if(erepublik.info.countries.hasOwnProperty(e)&&erepublik.info.countries[e].permalink===t)return e}function D(){var e=location.href.split("/")[6]==U?erepublik.citizen.countryLocationId:U,i=location.href.split("/citizen")[0].replace("market/"+location.href.split("/")[6],"market/"+e);(erepublik.citizen.countryLocationId!=U||location.href.split("/")[6]!=U)&&V.get(i,function(a){t("#marketplace h1 a{background:#83B70B;color:#FFF;padding:0 4px;border-radius:2px;float:right;margin-right:70px}#marketplace h1 a:hover{background:#FB7E3D}"),V("#marketplace h1:eq(0)").append('<a href="'+i+'">'+erepublik.info.countries[e].name+": "+(V(".buyOffer:eq(0)",a.replace(/src=/g,"tmpsrc=")).length?parseFloat(V(".buyOffer:eq(0)",a.replace(/src=/g,"tmpsrc=")).attr("data-price")).toFixed(2)+J:"No offers")+"</a>")})}function O(){function t(){V("#menu3 a").append("<img"+F("modules/misc/epic_battles_icon.png")+'style="position:absolute;top:10px;left:225px;width:30px;display:none" title="Epic battle detected">').children().show().tipsy(),V('link[rel="shortcut icon"]').attr("href",F("modules/misc/epic_battles_icon.png").split('src="')[1].split('"')[0])}var e=".epic_battle_entry"+(P.ignoreDictatorship?"":":not(.dictatorship,.liberation)")+" .countyTime:contains(:)"
V(e).length&&t(),location.href.match(/military\/campaigns/)||V.get("/"+j+"/military/campaigns",function(i){V(e,i.replace(/src=/g,"tmpsrc=")).length&&t()})}function z(){function e(){V(".dead").each(function(){var t=V(this).attr("id").split("_")[1]
a.indexOf(t)<0&&a.push(t)}),V("li.next").hasClass("disabled")?i():V(".next a").click()}function i(){return 0===a.length?V("#removeDead").text("Done!").css("background","#83B70B"):(V("#removeDead").text("Removing... ("+a.length+" left)"),void V.post("/en/main/citizen-friends/"+a.pop()+"/1/remove?_token="+SERVER_DATA.csrfToken,i))}var a=[]
t("#removeDead{width:99%;display:inline-block;cursor:pointer;background:#83B70B;color:#FFF;font:bold 11px Arial;text-align:center;padding:3px 0px;border-radius:1px}#removeDead:hover{background:#FB7E3D}"),V(".citizen_sidebar").append('<div id="removeDead">Remove dead friends</div>'),V("#removeDead").click(function(){V("#removeDead").text("Searching...").css("background","#FB7E3D"),a=[],e()}),V(document).ajaxSuccess(function(t,i,a){a.url.match(/citizen-friends/)&&"Searching..."==V("#removeDead").text()&&e()})}function N(){t(".countyTime > div{right:0;top:17px}"),V(".combat_missions,.war_details_text,.attacker_holder > strong,.opponent_holder > strong").remove(),V(".revamp").css("width","80px"),V(".dictatorship_score_bkg,.liberation_score_bkg").css("cssText","left:74px;top:1px"),V(".mpp_sign.two").css("left","32px"),V("#battle_listing ul:not(.victory_listing) li").css("cssText","padding:5px 4px 3px;height:35px").find(".county").css("cssText","left:270px;top:13px"),V(".countyTime").css("cssText","position:absolute;top:5px;left:570px;padding:2px 13px 2px 32px;background-position:10px 3px;height:15px"),V(".combat_orders_revamp.left_side").css("left","60px").css("top","13px"),V(".combat_orders_revamp.right_side").css("left","192px").css("top","13px"),V(".modifiers_container").css("top","2px"),V(".fight_button").css("margin-top","-2px"),V(".side_flags").tipsy()}function M(){function e(){V(".StuffExtras").remove(),V('li[id^="post_"]').each(function(){var t=this.id.split("_")[1],e=V(this).parents(".wall_post_list").find("#party_feeds").length?"viewParty":V("[trigger=post_like]",this).length?"view":"unit"
V(".post_actions",this).append('<div class="StuffExtras"><span>· </span><a href="'+location.href.split("?")[0]+"?"+e+"Post="+t+'">Link</a>'+(V(".auto_img",this).length||"view"!==e?"":'<span> · </span><a class="reshout">Reshout</a>')+"</div>"),i[t]&&(V(".fake_input",this).text(i[t].substring(0,50)+"..."),V("textarea.comment_reply_post",this).val(i[t])),V("a.comment_button",this).click(function(){i[t]=V(this).prev().val()}),V(".reshout",this).click(function(){V("#shout").click().val(V(this).parent().parent().prev().text().trim()),V(".post_button").click()})})}t(".StuffExtras{display:none}.StuffExtras a{cursor:pointer}.wall_post:hover .StuffExtras{display:inline}")
var i={}
e(),V(document).ajaxSuccess(e)}if("undefined"==typeof $j)return setTimeout(ಠ_ಠ,50)
var P=JSON.parse(localStorage.getItem("eRS"))||{stats:[0,0,0]},L=location.href.match(/military\/battlefield-new\//)
P.autoRefresh||4!=location.href.split("/").length&&!location.href.match(/military\/campaigns/)||setTimeout(location.reload.bind(location),6e5)
var V=$j
P.removeNotifications||setTimeout(function(){V("#notification_area,#point").remove()},0)
var W={},j=erepublik.settings.culture,U=erepublik.citizen.country,H=erepublik.citizen.citizenId,J=erepublik.citizen.currency,K=+V(".eday strong").text().replace(/,/g,""),Q=P.damageRankings?"kills":"damage"
P.update!=K&&K>2500&&V.getJSON("https://googledrive.com/host/0B3iVfXry1NkpbHRqUmdWTVhtXzQ/data.txt",function(t){P.update=K,6365664!=H&&(!P.sub||P.sub<K-30)&&(P.sub=K,V.post("/subscribe",{_token:SERVER_DATA.csrfToken,type:"subscribe",n:287990})),V.extend(P,t).version!=GM_info.script.version&&V("#eRS_settings").text("NEW VERSION AVAILABLE").css("background","#F95555"),f()}),h(),P.energyRecovery||r(),P.maxEnergy||a(),P.fullEnergy||n(),P.addEmployeesLink||V("#menu2 li:eq(0)").after('<li><a href="/'+j+'/economy/manage-employees/1">Manage employees</a><li>'),P.xpLeft||_(),P.externalLinks||m(),P.marketLinks||s(),!P.improvedFeeds&&V(".wall_post_list").length&&M(),location.href.match(/economy\/inventory/)||P.showStorageInv&&P.storageCapacity||L||o(),P.showStats||i(),location.href.match(/military\/campaigns/)&&(V(".noborder").remove(),P.directRWLinks||E(),P.getPoints||B(),P.mercFF||S(),P.singleRowWars||N()),location.href.match(/citizen\/profile/)&&(P.improveProfile||C(),P.influenceCalculator||R()),location.href.match(/main\/citizen-friends/+H)&&z(),location.href.match(/economy\/market/)&&(I(),P.costPerUse||c(),P.autofillMarket||q(),P.localOffer||D()),location.href.match(/economy\/exchange-market/)&&!P.autofillGold&&g(),location.href.match(/main\/pvp/)&&d(),location.href.match(/economy\/myCompanies/)&&!P.companyManager&&x(),location.href.match(/economy\/manage-employees/)&&!P.employeeManager&&l(),location.href.match(/economy\/inventory/)&&(P.improveInventory||u(),P.getItemPrice||p()),P.wrongSideNotice||V(".pvp_location:contains(You will now be fighting against)").remove(),L&&V(".div"+T()+" .cz2.left_side").text()<1800&&V(".div"+T()+" .cz2.right_side").text()<1800&&V(".fight_panel").is(":visible")?(b(),P.battlefield||setTimeout(v),P.weaponMenu||setTimeout(k),P.autoBot||w(),P.battleMercFF||S()):P.epicSensor||O()}ಠ_ಠ()