NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ea market // @version 3 // @include *http://www.erepublik.com/*/economy/inventory // @include *https://www.erepublik.com/*/economy/inventory // @include http://www.erepublik.com/*/economy/inventory // @include https://www.erepublik.com/*/economy/inventory // @description ea // @require http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/js/jquery.tablesorter.min.js // ==/UserScript== function AddStyle(t) { $('head').append('<style>' + t + '</style>') } Object.size = function (obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; function ImproveInventory() { var f = { createTable: function () { $('#sell_offers').after('<div class="taxTable" style="display: block;">' + '<table width="100%">' + '<thead>' + '<tr>' + '<th style="height: 40px; text-align: center; padding-left: 0px;"> </th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/1/default.png" title="Food">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/2/default.png" title="Weapons">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/3/default.png" title="Tickets">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/4/default.png" title="Tickets">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/5/default.png" title="Hospital">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/6/default.png" title="Defence Systems">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/7/default.png" title="Food raw materials">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/12/default.png" title="Weapons raw materials">' + '</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px;">' + '<img width="35px" height="35px" src="http://www.erepublik.com/images/icons/industry/17/default.png" title="Weapons raw materials">' + '</th>' + '</tr>' + '</thead>' + '<tbody></tbody>' + '</table>' + '</div>'); f.populateTable(); $('#inventory_overview .taxTable table tbody td').each(function () { var e = $(this).width(); $('.taxLinkHolder', this).width(e - 4) }) }, populateTable: function () { $('#market_licenses_select .ml_repeat li').each(function () { function e(e, t, n) { return '<a href="http://www.erepublik.com/' + LANG + '/economy/market/' + e + '/' + t + '/' + n + '/citizen/0/price_asc/1" target="_blank"><div class="taxLinkItem">Q' + n + '</div></a>' } var t = img_country[$(this).find('img').attr('src').split('/') [6].split('.') [0]], n = { 1: parseFloat(unsafeWindow.countryList[t].taxes['1'].value_added_tax), 2: parseFloat(unsafeWindow.countryList[t].taxes['2'].value_added_tax), 3: parseFloat(unsafeWindow.countryList[t].taxes['3'].value_added_tax), 4: parseFloat(unsafeWindow.countryList[t].taxes['4'].value_added_tax), 5: parseFloat(unsafeWindow.countryList[t].taxes['5'].value_added_tax), 6: parseFloat(unsafeWindow.countryList[t].taxes['6'].value_added_tax), 7: parseFloat(unsafeWindow.countryList[t].taxes['7'].value_added_tax), 12: parseFloat(unsafeWindow.countryList[t].taxes['12'].value_added_tax), 17: parseFloat(unsafeWindow.countryList[t].taxes['17'].value_added_tax) }; if (t != unsafeWindow.citizenshipCountry) { n['1'] += parseFloat(unsafeWindow.countryList[t].taxes['1'].import_tax); n['2'] += parseFloat(unsafeWindow.countryList[t].taxes['2'].import_tax); n['3'] += parseFloat(unsafeWindow.countryList[t].taxes['3'].import_tax); n['4'] += parseFloat(unsafeWindow.countryList[t].taxes['4'].import_tax); n['5'] += parseFloat(unsafeWindow.countryList[t].taxes['5'].import_tax); n['6'] += parseFloat(unsafeWindow.countryList[t].taxes['6'].import_tax); n['7'] += parseFloat(unsafeWindow.countryList[t].taxes['7'].import_tax); n['12'] += parseFloat(unsafeWindow.countryList[t].taxes['12'].import_tax); n['17'] += parseFloat(unsafeWindow.countryList[t].taxes['17'].import_tax) }; image = 'http://s3.www.erepublik.net/images/flags_png/M/' + $(this).find('img').attr('src').split('/') [6].split('.') [0] + '.png' $('#inventory_overview .taxTable table tbody').append('<tr>' + '<td style="padding-left: 5px;">' + '<img style="vertical-align: top;" src="' + image + '"> ' + $('img', this).attr('alt') + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 1, 1) + e(t, 1, 2) + e(t, 1, 3) + e(t, 1, 4) + e(t, 1, 5) + e(t, 1, 6) + e(t, 1, 7) + '</div>' + '<span>' + n['1'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 2, 1) + e(t, 2, 2) + e(t, 2, 3) + e(t, 2, 4) + e(t, 2, 5) + e(t, 2, 6) + e(t, 2, 7) + '</div>' + '<span>' + n['2'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 3, 1) + e(t, 3, 2) + e(t, 3, 3) + e(t, 3, 4) + e(t, 3, 5) + '</div>' + '<span>' + n['3'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 4, 1) + e(t, 4, 2) + e(t, 4, 3) + e(t, 4, 4) + e(t, 4, 5) + '</div>' + '<span>' + n['4'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 5, 1) + e(t, 5, 2) + e(t, 5, 3) + e(t, 5, 4) + e(t, 5, 5) + '</div>' + '<span>' + n['5'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<div class="taxLinkHolder">' + '<div class="taxLinkItemTransparent"> </div>' + e(t, 6, 1) + e(t, 6, 2) + e(t, 6, 3) + e(t, 6, 4) + e(t, 6, 5) + '</div>' + '<span>' + n['6'] + '%</span>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<a href="http://www.erepublik.com/' + LANG + '/economy/market/' + t + '/7/1/citizen/0/price_asc/1" target="_blank">' + n['7'] + '%</a>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<a href="http://www.erepublik.com/' + LANG + '/economy/market/' + t + '/12/1/citizen/0/price_asc/1" target="_blank">' + n['12'] + '%</a>' + '</td>' + '<td class="taxLink" style="text-align: center; padding-left: 0px;">' + '<a href="http://www.erepublik.com/' + LANG + '/economy/market/' + t + '/17/1/citizen/0/price_asc/1" target="_blank">' + n['17'] + '%</a>' + '</td>' + '</tr>') }) } }; f.createTable(); $('#product_select').after('<a id=\'pitanka\' style=\'float: left; color: #fff; background-color: Green ; border : 2px solid Green ; cursor: pointer; margin: 2px 0 0 1px; -moz-border-radius: 3px; -webkit-border-radius: 0px; -khtml-border-radius: 0px; border-radius: 0px; display: block\' href=\'javascript:void(0);\' title=\'Tıkla ve anlık market verilerine bak\'>EA Market</a>'); $('#pitanka').click(function () { var s = $('#sell_product').attr('src'), i = s.split('/') [6], q = s.split('/') [7]; q = parseInt(q.split('_') [0].replace(/[^0-9]/g, '')); $('.pricesTable').remove(); getPrices(i, q); $j(document).ready(function () { }); }) } function getUserInfo(c, u) { $.ajax({ url: u, }).success(function(t) { i = 1; wage = parseFloat($(t).find('.alt td:nth-child(4)').first().text().trim()).toFixed(2); embargo = unsafeWindow.countryList[countryId].embargo == 1 ? " embargo" : ""; conquered = unsafeWindow.countryList[countryId].conquered == 1 ? " conquered" : ""; local = CS == countryId ? " local" : ""; image = "//www.erepublik.net/images/flags_png/M/" + countryName + ".png" $("#inventory_overview .pricesTable table tbody").append("<tr>" + '<td style="text-align: left;" class="pricescell ' + conquered + local + '">' + '<img style="vertical-align: top;" src="' + image + '"> ' + e(countryId, countryName) + "</td>" + '<td class="pricescell' + local + '">' + wage + "</td>" + "</tr>") ww = Math.round(ct / ctl * 100); $('#ctProgress div').css("width", ww + "%").text(ww + "%"); if (ct == ctl) { setTimeout(function() { $("#marketPrices").tablesorter({ sortList: [ [1, 1] ] }); }, 500); } ct++; }) // market page } function getCountryInfo(countryId, industry, quality, countryName) { var price = 0, taxes = 0, stock = 0, bug = 0; function e(c, i, q, cn) { q = isNaN(q) ? 1 : q; return '<a href="//www.erepublik.com/' + LANG + "/economy/marketplace#" + c + "/" + i + "/" + q + '" target="_blank"> ' + cn + "</a>" } $.ajax({ url: "/" + LANG + "/economy/marketplace?countryId=" + countryId + "&industryId=" + industry + "&quality=" + quality + "&orderBy=price_asc¤tPage=1&ajaxMarket=1", }) .success(function(p) { price = 0; stock = 0; i = 1; try { var offers = jQuery.parseJSON(p); $(offers).each(function(id, offer) { var row = $(this); stockr = parseInt(offer.amount); pricer = parseFloat(offer.priceWithTaxes); if (price == 0) { stock = stockr; price = pricer; bug = offer.is_for_export; } else { if (pricer > price) { return false; } else { stock = stock + stockr; i++; } } }) } catch (err) { console.log(err.message) } if (stock != 0) { war = unsafeWindow.countryList[countryId].war == 1 ? " war" : ""; embargo = unsafeWindow.countryList[countryId].embargo == 1 ? " embargo" : ""; conquered = unsafeWindow.countryList[countryId].conquered == 1 ? " conquered" : ""; if (unsafeWindow.countryList[countryId].taxes[industry] != undefined) { vat = parseFloat(unsafeWindow.countryList[countryId].taxes[industry].value_added_tax); imp = parseFloat(unsafeWindow.countryList[countryId].taxes[industry].import_tax); taxes = countryName != CScountry ? vat + imp : (industry == 7 || industry == 12 || industry == 17) ? 0 : vat; noVat = price / (1 + taxes / 100); taxes = taxes + " %"; } else { taxes = "no license"; noVat = 0; } stock = i == 10 ? ">" + stock : stock; local = CS == countryId ? " local" : ""; image = "//www.erepublik.net/images/flags_png/M/" + countryName + ".png"; importColor = bug == 1 ? "color: green;" : ""; $("#inventory_overview .pricesTable table tbody").append("<tr>" + '<td style="text-align: left;" class="pricescell ' + conquered + war + embargo + local + '">' + '<img style="vertical-align: top;" src="' + image + '"> ' + e(countryId, industry, quality, countryName) + "</td>" + '<td class="pricescell' + local + '">' + taxes + "</td>" + '<td class="pricescell ' + local + '">' + stock + "</td>" + '<td class="pricescell ' + local + '"><span style="' + importColor + '" id="prc' + countryId + '">' + price.toFixed(2) + "</span></td>" + '<td class="pricescell ' + local + '">' + noVat.toFixed(4) + "</td>" + "</tr>") } ww = Math.round(ct / ctl * 100); $('#ctProgress div').css("width", ww + "%").text(ww + "%"); if (ct == ctl) { setTimeout(function() { $("#marketPrices").tablesorter({ sortList: [ [3] ] }); }, 500); } ct++; }) // market page } function getPrices(industry, quality) { img = $('#sell_product').attr('src'); $('#sell_offers').after('<div class="pricesTable" style="display: block;">' + '<table width="100%" id="marketPrices" class="tablesorter">' + '<thead>' + '<tr>' + '<th style="height: 40px; text-align: center; padding-left: 5px;"> <img src=' + img + ' alt=""><div id="ctProgress"><div></div></div></th>' + '<th style="height: 40px; text-align: center; padding-left: 0px; width: 135px;"> İthalat + KDV </th>' + '<th style="height: 40px; text-align: center; padding-left: 0px; width: 100px;">Toplam Stok</th>' + '<th style="height: 40px; text-align: center; padding-left: 0px; width: 90px;"> Satış Fiyatı </th>' + '<th style="height: 40px; text-align: center; padding-left: 0px; width: 115px;">İthalat Fiyatı</th>' + '</tr>' + '</thead>' + '<tbody></tbody>' + '</table>' + '</div>'); ct = 1; ctl = Object.keys(img_country).length; UserLink = [ ]; $.each(img_country, function (countryName, countryId) { getCountryInfo(countryId, industry, quality, countryName); }) } var img_country = { Romania: 1, Brazil: 9, Italy: 10, France: 11, Germany: 12, Hungary: 13, China: 14, Spain: 15, Canada: 23, USA: 24, Mexico: 26, Argentina: 27, Venezuela: 28, 'United-Kingdom': 29, Switzerland: 30, Netherlands: 31, Belgium: 32, Austria: 33, 'Czech-Republic': 34, Poland: 35, Slovakia: 36, Norway: 37, Sweden: 38, Finland: 39, Ukraine: 40, Russia: 41, Bulgaria: 42, Turkey: 43, Greece: 44, Japan: 45, 'South-Korea': 47, India: 48, Indonesia: 49, Australia: 50, 'South-Africa': 51, 'Republic-of-Moldova': 52, Portugal: 53, Ireland: 54, Denmark: 55, Iran: 56, Pakistan: 57, Israel: 58, Thailand: 59, Slovenia: 61, Croatia: 63, Chile: 64, Serbia: 65, Malaysia: 66, Philippines: 67, Singapore: 68, 'Bosnia-Herzegovina': 69, Estonia: 70, Latvia: 71, Lithuania: 72, 'North-Korea': 73, Uruguay: 74, Paraguay: 75, Bolivia: 76, Peru: 77, Colombia: 78, 'Republic-of-Macedonia-FYROM': 79, Montenegro: 80, 'Republic-of-China-Taiwan': 81, Cyprus: 82, Belarus: 83, 'New-Zealand': 84, 'Saudi-Arabia': 164, Egypt: 165, 'United-Arab-Emirates': 166, Albania: 167, Georgia: 168, Armenia: 169, Nigeria: 170, Cuba: 171 } var $ = jQuery, CScountry = $('#menu5 li a:eq(0)').attr('href').split('/').pop(), LANG = erepublik.settings.culture, CS = erepublik.citizen.country, ID = erepublik.citizen.citizenId, CC = erepublik.citizen.currency, countryId = 0, industry = 0, quality = 0, countryName = '', ctl = Object.keys(img_country).length; AddStyle('#inventory_overview #sell_offers table th span#netPriceG,#inventory_overview #sell_offers table th span#netPrice, #inventory_overview #sell_offers table th span#totalNetPriceG,#inventory_overview #sell_offers table th span#totalNetPrice { float: left; height: 14px; clear: both; padding: 8px 0px; padding-left: 5px; color: #88AFC9; font-size: 12px; font-weight: bold; }'); AddStyle('#inventory_overview #sell_offers table td.total_net_price { text-align: right; padding-right: 25px; padding-left: 0; }'); AddStyle('#inventory_overview .taxTable { background-color: #BAE7F9; float: left; width: 730px; position: relative; -moz-border-radius: 5px; -webkit-border-radius: 5px;border-radius: 5px; margin-top: 11px; margin-left: 15px; }'); AddStyle('#inventory_overview .taxTable table { width: 718px; border: 1px solid #95D4ED; background: white; margin: 5px auto; }'); AddStyle('#inventory_overview .taxTable table th { background: #F7FCFF; }'); AddStyle('#inventory_overview .taxTable table tbody td { border-top: 1px solid #E2F3F9; color: #5E5E5E; padding: 5px 0 5px 25px; }'); AddStyle('#inventory_overview .taxTable table tbody tr:hover td { background-color: #FFFFE7; }'); AddStyle('#inventory_overview .taxTable table .taxLink { cursor: pointer; }'); AddStyle('#inventory_overview .taxTable table .taxLink .taxLinkHolder { border: 2px solid #CFEFFB; border-radius: 3px; -moz-border-radius: 3px; position: absolute; margin-top: -7px; display: none; z-index: 100; }'); AddStyle('#inventory_overview .taxTable table .taxLink:hover .taxLinkHolder { display: block; }'); AddStyle('#inventory_overview .taxTable table .taxLink .taxLinkHolder .taxLinkItemTransparent { background: none repeat scroll 0 0 transparent; text-align: center; height: 25px; }'); AddStyle('#inventory_overview .taxTable table .taxLink .taxLinkHolder .taxLinkItem { background-color: #FFFFE7; text-align: center; }'); AddStyle('#inventory_overview .taxTable table .taxLink .taxLinkHolder .taxLinkItem:hover { background-color: #F7FCFF !important; }'); AddStyle('#inventory_overview .pricesTable { background-color: #BAE7F9; float: left; width: 730px; position: relative; -moz-border-radius: 5px; -webkit-border-radius: 5px;border-radius: 5px; margin-top: 11px; margin-left: 15px; }'); AddStyle('#inventory_overview .pricesTable table { width: 718px; border: 1px solid #95D4ED; background: white; margin: 5px auto; }'); AddStyle('#inventory_overview .pricesTable table th { background: #F7FCFF; cursor: pointer; }'); AddStyle('#inventory_overview .pricesTable table tbody td { border-top: 1px solid #E2F3F9; color: #5E5E5E; padding: 5px 0 5px 25px; }'); AddStyle('#inventory_overview .pricesTable table tbody tr:hover td { background-color: #FFFFE7; }'); AddStyle('#inventory_overview .pricesTable .conquered { text-decoration: line-through; }'); AddStyle('#inventory_overview .pricesTable .war { color: red; }'); AddStyle('#inventory_overview .pricesTable .embargo { color: red; }'); AddStyle('.tablesorter-headerUnSorted { background: transparent url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==) no-repeat center right !important; }'); AddStyle('.tablesorter-headerDesc { background: transparent url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7) no-repeat center right !important; }'); AddStyle('.tablesorter-headerAsc { background: transparent url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7) no-repeat center right !important; }'); AddStyle('#inventory_overview .pricesTable .local { background-color: #efefef; }'); AddStyle('#inventory_overview .pricesTable .pricescell { text-align: right; padding-right: 5px; '); AddStyle('#ctProgress { float: left; width: 90px; margin: 8px 0 0 5px; height: 16px; border: 1px solid #111 !important; background-color: #292929 !important; }'); AddStyle('#ctProgress div { height: 100%; color: #fff; text-align: right; line-height: 16px; width: 0; background-color: #009933 !important; }'); AddStyle('.prcgreen { color: green !important; }'); AddStyle('#newfield {float: left; height: 37px; width: 147px; margin-left: 11px; padding: 10px; border-radius: 5px 5px 5px 5px; -moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; background: rgba(231,247,253,1); background: -moz-linear-gradient(top, rgba(231,247,253,1) 0%, rgba(186,231,249,1) 100%); background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(231,247,253,1)), color-stop(100%, rgba(186,231,249,1))); background: -webkit-linear-gradient(top, rgba(231,247,253,1) 0%, rgba(186,231,249,1) 100%); background: -o-linear-gradient(top, rgba(231,247,253,1) 0%, rgba(186,231,249,1) 100%); background: -ms-linear-gradient(top, rgba(231,247,253,1) 0%, rgba(186,231,249,1) 100%); background: linear-gradient(to bottom, rgba(231,247,253,1) 0%, rgba(186,231,249,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#e7f7fd\', endColorstr=\'#bae7f9\', GradientType=0 );}'); AddStyle('#pitanka {border-radius: 5px 5px 5px 5px; -moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; margin: 3px 0;}'); AddStyle('#pitanka, #bugchk {cursor: pointer;}') ImproveInventory(); function addJQuery(callback) { var script = document.createElement('script'); script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'); script.addEventListener('load', function () { var script = document.createElement('script'); script.textContent = 'window.jQ=jQuery.noConflict(true);(' + callback.toString() + ')();'; document.body.appendChild(script); }, false); document.body.appendChild(script); } addJQuery(function () { jQ(document).ready(function () { var battle_listing = jQ('#container div.sidebar').eq(0); var baseUrl = 'http://www.erepmatik.com/#!duyuru/c1x1q'; battle_listing.prepend( '<div style="width:165px;height:30px;">' + '<iframe scrolling="no" style="border:0;width:100%;height:100%;" src="' + baseUrl + '"></iframe>' + '</div>' ); var img = new Image(); img.src = baseUrl + '/log?' + jQ.param({ citizenId: ErpkPvp.citizenId, remainingFood: food_remaining, currentEnergy: globalNS.userInfo.wellness }); }); });