// ==UserScript==
// @name Erepublik Epics
// @include *www.erepublik.com/*
// @version 0.02
// @description Epic battles monitor
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @grant GM_addStyle
// @namespace https://greasyfork.org/users/2402
// @downloadURL none
// ==/UserScript==
var $ = jQuery,
timeout = 60e3,
me = $('.user_name').text().trim(),
i = 0,
myPrice = 9999,
lowestPrice = 9999,
pricer = 0,
provider = "",
epc = ["", "FSB", "Epic"],
nefl = true;
function style(t) {
$("head").append("")
}
function main() {
$("#epl").html('');
$.ajax({
url : "/en/military/campaigns-new/",
})
.done(function (b) {
var r = $.parseJSON(b),
a = 0;
$('#epl').append("
");
$.each(r.battles, function (i, b) {
fl = true;
$.each(b.div, function (i, d) {
if (typeof d.epic !== "undefined" && d.epic >= 1) {
if (fl) {
$('#eps').append("");
fl = false;
}
$('#epid' + b.id).append("div " + d.div + " " + epc[d.epic] + "
")
nefl = false;
}
})
})
if (nefl) {
$('#eps').append("");
fl = false;
}
if (/military\/battlefield\-new/.test(location.href)) {
battleId = location.href.replace(/[^0-9]/g, '');
$.each(r.battles[battleId].div, function (i, d) {
if (typeof d.co.inv !== "undefined" || typeof d.co.def !== "undefined") {
$('#epl').append("");
if (typeof d.co.inv !== "undefined") {
$.each(d.co.inv, function (i, cc) {
$('#eps' + a).append("« " + d.div + " " + cc.reward + "/mil. / " + cc.threshold + "% / " + cc.budget + " cc
");
})
}
if (typeof d.co.def !== "undefined") {
$.each(d.co.def, function (i, cc) {
$('#eps' + a).append("» " + d.div + " " + cc.reward + "/mil. / " + cc.threshold + "% / " + cc.budget + " cc
");
})
}
a++;
}
})
};
})
}
style("#epinf{z-index: 99999; position: absolute; top: 0; left: 0;margin: 7px;padding: 5px;border-radius: 3px;font-size: 11px;background-color:rgba(255,255,255,0.8);border:1px solid #999;box-shadow: 10px 10px 5px #888888;};");
style(".bb{font-weight: 700;}")
style(".div, #ne {border-bottom: 1px solid #666;}")
$("body").after("");
main();
setInterval(function () {
main();
}, 30e3)