NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name eR Fix+ // @version 0.2.5 // @author Runy69 // @include *www.erepublik.com/* // @require http://www.erepublik.com/js/jquery.tipsy.js?1412241140 // @updateURL https://googledrive.com/host/0B8c6DgXq6gcGMVBBUTdqbVlrWGc/eRFix.meta.js // @downloadURL https://googledrive.com/host/0B8c6DgXq6gcGMVBBUTdqbVlrWGc/eRFix.user.js // ==/UserScript== J = jQuery; J('head').append('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">'); var url = location.toString(); //CALC DAMAGE function getRank() { var aRank = J(".citizen_military_box_wide img").attr("src").split("/")[6].split(".")[0].split("_"); return +aRank.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][aRank.join("_")]; } function getInfluence(strength, wep) { var rank = getRank(); var influence = 10*(1+strength/400)*(1+rank/5)*(1+wep/100); return parseInt(influence); } //EXPORT LEADERBOARDS exportJsonToCSV = function(cabeceras,myObj,filename) { var csv = ""; J.each(myObj,function(indice,valor) { csv += "\n"; J.each(valor,function(k,v){ if(k == "id" || k == "name" || k == "values" || k == "myDivision") { csv += v + ";"; } }); }); csv = cabeceras + csv; csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv); J('<a></a>') .attr('id','downloadFile') .attr('href', csvData) .attr('download',filename) .appendTo('body'); J('#downloadFile').ready(function() { J('#downloadFile').get(0).click(); J('#downloadFile').remove(); }); }; function lbToCsv(filename, mode, country, week, mu, div){ var url = "https://www.erepublik.com/es/main/leaderboards-"+mode+"-rankings/"+(mode.match(/co/i) ? week : country+"/"+week+"/"+mu+"/"+div); J.ajax({ dataType: "json", url: url, data: "", success: function(data) { var arrData = (typeof data.top != 'object' ? JSON.parse(data.top) : data.top); var titulos = 'ID;Nick;Damage;Div'; exportJsonToCSV(titulos,arrData,filename); } }); } //LINK IN WALL POST function start() { var aCUrl = J(location).attr('pathname').split('/'); if(aCUrl.length > 2) { return; } scan(); observeNewComments(); } function observeNewComments() { var target = document.querySelector('#wall_master'); var observer = new MutationObserver(function(mutations) { scan(); }); var config = { childList: true, subtree: true }; observer.observe(target, config); } function scan() { var aCUrl = J(location).attr('pathname').split('/'); var cLang = aCUrl[1]; var postType = J('#show_friends_feed').hasClass('active') ? 'viewPost=' : J('#show_regiment_feed').hasClass('active') ? 'unitPost=' : 'viewPartyPost='; J('.wall_post').each(function(index){ if(!J(this).attr('hasLink') && !J(this).hasClass('mu')) { var medal = J('div h6 strong', this).length > 0; var id = J(this).attr('id').replace('post_', ''); J(this).find('.post_actions') .append(' <span>·</span> ') .append('<a href="https://www.erepublik.com/'+ cLang + '?' + postType + id + '">Link</a>' + (medal ? "" : ' <span>·</span> <a class="reshout" href="javascript:;">Reshout</a>')); J(this).attr('hasLink', true); } }); } J(document).ready(function(){ start(); if(url.match(/profile/)) { //CT var pXP, paXP, pbXP, pStr, pTI, pHTML, pHTML1, strS, strT, aCUrl, cLang; var weapon=[0, 20, 40, 60, 80, 100, 120, 200]; var uses=[0, 1, 2, 3, 4, 5, 6, 10]; var influence=[]; paXP = J('strong.citizen_level').attr('original-title').split('>'); pbXP = paXP[3].split('/'); pXP = parseFloat(pbXP[0].trim().replace(/,/g, '')); pStr = parseFloat(J('div.citizen_military_box span:eq(1)').text().trim().replace(/,/g, '')); pTI = (pXP/pStr).toFixed(4); aCUrl = J(location).attr('pathname').split('/'); cLang = aCUrl[1]; //Language strings //If you want to translate them into your language please send me a message with the translated sentences and which language is it (en, es, etc). switch(cLang){ case 'es'://Spanish strS = 'Coeficiente Tanque'; strT = 'Mientras más bajo mejor'; break; case 'en'://English strS = 'Tank Rating'; strT = 'The lower the better'; break; default: strS = 'Tank Rating'; strT = 'The lower the better'; } pHTML = '\ <style>\ #tank_meter {width: 100%; height: 6px; border: solid 1px #e0e0e0; border-radius: 5px; -webkit-border-radius: 5px;}\ #scale {display: table; width: 100%; padding: 0px 0px 0px 0px; margin: 2px 0px 0px 0px; border: 0px 0px 0px 0px; color: #999; font-weight: bold;}\ #scale li {width: 10%; display: table-cell; white-space: nowrap; font-size: 8px;}\ </style>\ <div class="citizen_military" style="margin: 0 0 3px 0;">\ <strong>'+strS+'</strong>\ <h4 style="margin-left:40px">'+pTI+'</h4>\ <div class="stat">\ <div style="width: 162px;">\ <meter id="tank_meter" min=0 low=2 high=4 max=5 optimum=-1 value='+pTI+' title="'+strT+'"></meter>\ <ul id="scale">\ <li><span id="scale">0</span></li>\ <li><span id="scale">1</span></li>\ <li><span id="scale">2</span></li>\ <li><span id="scale">3</span></li>\ <li><span id="scale">4</span></li>\ </ul>\ </div>\ </div>\ </div>'; var i=0; for(i=0;i<weapon.length;i++){ influence[i]=getInfluence(pStr,weapon[i]); } //DAMAGE var bar='\ <div class="bar damage" style="width:98%">\ <div class="border">\ </div>\ <div class="fill">\ <span id="q0" style="width:9%;" class="mids" original-title=""></span>\ <span id="q1" style="width:9%; background-color: #60B1DD; background-image: linear-gradient(#91C8E7 0px, #60B1DD 100%); border-bottom-color: #5892C1; border-top-color: #5892C1;" class="mids" original-title=""></span>\ <span id="q2" style="width:9%;" class="mids" original-title=""></span>\ <span id="q3" style="width:9%; background-color: #60B1DD; background-image: linear-gradient(#91C8E7 0px, #60B1DD 100%); border-bottom-color: #5892C1; border-top-color: #5892C1;" class="mids" original-title=""></span>\ <span id="q4" style="width:9%;" class="mids" original-title=""></span>\ <span id="q5" style="width:9%; background-color: #60B1DD; background-image: linear-gradient(#91C8E7 0px, #60B1DD 100%); border-bottom-color: #5892C1; border-top-color: #5892C1;" class="mids" original-title=""></span>\ <span id="q6" style="width:9%;" class="mids" original-title=""></span>\ <span id="q7" style="width:37%; background-color: #60B1DD; background-image: linear-gradient(#91C8E7 0px, #60B1DD 100%); border-bottom-color: #5892C1; border-top-color: #5892C1;" class="mids" original-title=""></span>\ </div>\ </div>'; pHTML1 = '\ <div class="citizen_military" style="margin-bottom: 15px;">\ <strong>Influencia</strong>\ <div class="stat" style="width:70%" style="margin-top:5px">\ <table width="100%" border="0" class="barholder">\ <tbody>\ <tr>\ <td>'+bar+'\ </td>\ </tr>\ </tbody>\ </table>\ <small style="width:95%; margin-left:0px;"><strong style="margin:0; left:0px;">Da�o Base: '+influence[0]+'</strong><strong style="margin:0;">Max-Hit: '+influence[7]+'</strong></small>\ </div>\ </div>'; J('.citizen_military').css({"margin-bottom":"3px"}); J('div.citizen_military:eq(0)').after(pHTML); J('div.citizen_military:eq(1)').after(pHTML1); for(var i=0;i<8;i++){ var info="<center><h4>"+(i===0 ? "Sin Arma" : "Arma Q" + i)+"</h4><br/>\ "+(i===0 ? "<div>" : "<img height='60px' width='60px' src='https://www.erepublik.net/images/icons/industry/2/q"+i+"_90x90.png'/><div style='float: right'>" )+"\ <strong>Influencia:</strong> "+influence[i]+"<br/>\ <strong>Potencia:</strong> "+(100+weapon[i])+"%<br/>\ "+(i===0 ? "": ("<strong>Usos</strong>: "+uses[i]+"<br/>"))+"</div></center>"; J('#q' + i).tipsy({gravity: 's', html: true}).attr("original-title", info); } } else if(url.match(/mycompanies/i)) { J(".c4").css("width","135px"); J(".c5").css("width","140px"); J(".current_tickets").css("top","92px"); J(".current_tickets").css("left","65px"); J(".current_tickets").css("bottom","auto"); J(".current_tickets").css("right","auto"); J(".overtime_tickets_info img").css("margin-top","0px"); } else if(url.match(/inventory/)){ if(J('#sell_offers table tfoot').length == 0) J('#sell_offers table').append('<tfoot></tfoot>'); var licenses = J('.ml_repeat:first .ml_selector'); var HTML = '<tr><td colspan="6"><h1 style="margin-left: 15px;" class="offer_ammount">Impuestos en paises con licencia</h1></td><td style="text-align: right!important; padding-right: 15px!important;"><strong>Importacion</strong><br><strong>IVA</strong></td></tr>'; HTML += '<tr><td colspan="2">Pais</td><td>Comida</td><td>Armas</td><td>Tickets</td><td>Casas</td><td style="padding-left: 45px!important;">Raw</td></tr>'; J('#sell_offers table tfoot').append(HTML); for(i=0;i<licenses.length;i++){ var id = J(licenses[i]).attr('country'); var ctry = erepublik.info.countries[id].permalink; var link = "https://www.erepublik.com/es/country/economy/" + ctry; var HTML = '<tr>'; HTML += '<td>'; HTML += '<img class="offer_image" src="https://static.erepublik.net/images/flags_png/M/'+ctry+'.png">'; HTML += '</td>'; HTML += '<td>'; HTML += '<strong class="offer_amount">'+ctry+'</strong>'; HTML += '</td>'; HTML += '<td>'; HTML += '<strong class="offer_amount" id="fIm-'+ctry+'"></strong><br>'; HTML += '<strong class="offer_amount" id="fVat-'+ctry+'"></strong>'; HTML += '</td>'; HTML += '<td>'; HTML += '<strong class="offer_amount" id="wIm-'+ctry+'"></strong><br>'; HTML += '<strong class="offer_amount" id="wVat-'+ctry+'"></strong>'; HTML += '</td>'; HTML += '<td>'; HTML += '<strong class="offer_amount" id="tIm-'+ctry+'"></strong><br>'; HTML += '<strong class="offer_amount" id="tVat-'+ctry+'"></strong>'; HTML += '</td>'; HTML += '<td>'; HTML += '<strong class="offer_amount" id="hIm-'+ctry+'"></strong><br>'; HTML += '<strong class="offer_amount" id="hVat-'+ctry+'"></strong>'; HTML += '</td>'; HTML += '<td style="padding-left: 25px!important;">'; HTML += '<strong class="offer_amount" id="frm-'+ctry+'"></strong>'; HTML += '<strong class="offer_amount" id="wrm-'+ctry+'"></strong>'; HTML += '<strong class="offer_amount" id="hrm-'+ctry+'"></strong>'; HTML += '</td>'; HTML += '</tr>'; J('#sell_offers table tfoot').append(HTML); J.ajax({ url: link, context: document.body, success: function(data) { var ctrya = data.match(/eRepublik Country Economy \| ([^"]+)/)[1].replace(/ /, "-"); var taxes = data.match(/special">(\d+\.\d+|\d+)/g); J('#fIm-'+ctrya).empty().append(taxes[4].split(">")[1]+'%'); //Food Import J('#fVat-'+ctrya).empty().append(taxes[5].split(">")[1]+'%'); //Food Vat J('#wIm-'+ctrya).empty().append(taxes[7].split(">")[1]+'%'); //Weapon Import J('#wVat-'+ctrya).empty().append(taxes[8].split(">")[1]+'%'); //Weapon Vat J('#tIm-'+ctrya).empty().append(taxes[10].split(">")[1]+'%'); //Ticket Import J('#tVat-'+ctrya).empty().append(taxes[11].split(">")[1]+'%'); //Ticket Vat J('#hIm-'+ctrya).empty().append(taxes[13].split(">")[1]+'%'); //House Import J('#hVat-'+ctrya).empty().append(taxes[14].split(">")[1]+'%'); //House Vat J('#frm-'+ctrya).empty().append('W: '+taxes[16].split(">")[1]+'%'); //FRM Import J('#wrm-'+ctrya).empty().append(' F: '+taxes[18].split(">")[1]+'%'); //WRM Import J('#hrm-'+ctrya).empty().append(' H: '+taxes[20].split(">")[1]+'%'); //HRM Import } }); } } else if(url.match(/leaderboards-damage/i)){ J('.selectors_area a').after('<a class="open_settings" id="exportToXls" href="javascript:;" original-title="Export Data to Spreadsheet" style="right: 50px!important; text-align: center;"><i class="fa fa-download" style="font-size: 2em; margin-top: 2px; color: white;"></i></a>'); J('#exportToXls').on('click', function() { var mode = erepublik.leaderboard.getCurrentTab(); var week = parseInt(J("#leaderboard_week").val(),10); var countryId = J("#leaderboard_flag").val(); var muId = J("#leaderboard_mu").val(); var div = J("#leaderboard_divisions").val(); var eday = J('.eday').text().replace(/[^\d]/g, ""); var daysLeft = J('.timer_days').text().replace(/[^\d]|0/g, ""); var filename = mode; if(mode.match(/co/i)) countryId = 0; filename += (muId!=0 ? " - MU "+muId : (countryId == 0? "" : " - Country "+countryId))+(div!=0 ? " - Div "+div : "")+' - '+(eday-(daysLeft-6))+"-"+(parseInt(eday)+parseInt(daysLeft))+'.csv'; lbToCsv(filename ,mode, countryId, div, muId, week); }); } else if(url.split("/".length<5)){ J('.info small').css({"width":"150px"}); J('.reshout').click(function(){ J("#shout").click().val(J(this).parent().parent().find('p').text().trim()), J(".post_button").click(); }); } });