// ==UserScript== // @name eRepublik Licenses and taxes // @version 0.1.4 // @include *http://www.erepublik.com/*/economy/inventory // @description Added table with licenses and taxes // @require http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/js/jquery.tablesorter.min.js // @namespace https://greasyfork.org/users/2402 // @downloadURL none // ==/UserScript== function AddStyle(t) { $("head").append("") } function ImproveInventory() { var f = { createTable: function() { $("#sell_offers").after('
' + '' + "" + "" + '' + '" + '" + '" + '" + '" + '" + '" + '" + '" + "" + "" + "" + "
' + '' + "' + '' + "' + '' + "' + '' + "' + '' + "' + '' + "' + '' + "' + '' + "' + '' + "
" + "
"); 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 '
Q' + n + "
" } 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("" + '' + ' ' + $("img", this).attr("alt") + "" + '' + '
' + '
' + 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) + "
" + "" + n["1"] + "%" + "" + '' + '
' + '
' + 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) + "
" + "" + n["2"] + "%" + "" + '' + '
' + '
' + e(t, 3, 1) + e(t, 3, 2) + e(t, 3, 3) + e(t, 3, 4) + e(t, 3, 5) + "
" + "" + n["3"] + "%" + "" + '' + '
' + '
' + e(t, 4, 1) + e(t, 4, 2) + e(t, 4, 3) + e(t, 4, 4) + e(t, 4, 5) + "
" + "" + n["4"] + "%" + "" + '' + '
' + '
' + e(t, 5, 1) + e(t, 5, 2) + e(t, 5, 3) + e(t, 5, 4) + e(t, 5, 5) + "
" + "" + n["5"] + "%" + "" + '' + '
' + '
' + e(t, 6, 1) + e(t, 6, 2) + e(t, 6, 3) + e(t, 6, 4) + e(t, 6, 5) + "
" + "" + n["6"] + "%" + "" + '' + '' + n["7"] + "%" + "" + '' + '' + n["12"] + "%" + "" + '' + '' + n["17"] + "%" + "" + "") }) } }; f.createTable(); $("#product_select").after(" ? "); $("#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, "")); $("#marketPrices").remove(); getPrices(i, q); }) } function getPrices(industry, quality) { var price = 0, taxes = 0, stock = 0; function e(c, i, q, cn) { q = isNaN(q) ? 1 : q; return ' ' + cn + "" } img = $("#sell_product").attr("src"); $("#sell_offers").after('
' + '' + "" + "" + '' + '' + '' + '' + '' + "" + "" + "" + "
Taxes (import+vat) Stock (total) Sell price Price w.o. taxes
" + "
"); $.each(img_country, function(countryName, countryId) { $.ajax({ url: "/" + LANG + "/economy/market/" + countryId + "/" + industry + "/" + quality, async: false, }) .done(function(t) { price = 0; stock = 0; i = 1; table = $(t).find('#content table td.m_product').parent(); $(table).each(function() { var row = $(this); stockr = parseInt($.trim($(row[0]).find('.m_stock').text()).replace(/[^0-9]/, "")); pricer = $(row[0]).find('.m_price'); pricer = parseFloat($.trim(pricer.find('> strong').text()) + $.trim(pricer.find('sup').contents().filter(function() { return this.nodeType == 3 }).text())); if (price == 0) { stock = stockr; price = pricer; } else { if (pricer > price) { return false; } else { stock = stock + stockr; i++; } } }) }) 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["1"].value_added_tax); imp = parseFloat(unsafeWindow.countryList[countryId].taxes["1"].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 = "http://s3.www.erepublik.net/images/flags_png/M/" + countryName + ".png" $("#inventory_overview .pricesTable table tbody").append("" + '' + ' ' + e(countryId, industry, quality, countryName) + "" + '' + taxes + "" + '' + stock + "" + '' + price.toFixed(2) + "" + '' + noVat.toFixed(4) + "" + "") }) $("#marketPrices").tablesorter({ sortList: [ [3] ] }); } 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 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; "); ImproveInventory();