Greasy Fork

来自缓存

Erepublik Epics

Epic battles monitor

当前为 2016-10-09 提交的版本,查看 最新版本

// ==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
// ==/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("<style>" + t + "</style>")
}

function main() {
	$("#epl").html('');
	$.ajax({
		url : "/en/military/campaigns-new/",
	})
	.done(function (b) {
		var r = $.parseJSON(b),
		a = 0;
		$('#epl').append("<div id='eps'></div>");
		$.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("<div id='epid" + b.id + "'><p> &gt;&gt; <a href='/en/military/battlefield-new/" + b.id + "'>" + b.region.name + "</a></p></div>");
						fl = false;
					}
					$('#epid' + b.id).append("<div><b>div " + d.div + " " + epc[d.epic] + "</b></div>")
					nefl = false;
				}
			})
		})
		if (nefl) {
			$('#eps').append("<div id='ne'><p> No epics :-(</p></div>");
			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("<div id='eps" + a + "'></div>");
					if (typeof d.co.inv !== "undefined") {
						$.each(d.co.inv, function (i, cc) {
							$('#eps' + a).append("<div class='div'>« " + d.div + " <span>" + cc.reward + "/mil.</span><span>  / " + cc.threshold + "%</span><span>  / " + cc.budget + " cc </span></div>");
						})
					}
					if (typeof d.co.def !== "undefined") {
						$.each(d.co.def, function (i, cc) {
							$('#eps' + a).append("<div class='div'>» " + d.div + " <span>" + cc.reward + "/mil.</span><span>  / " + cc.threshold + "%</span><span>  / " + cc.budget + " cc </span></div>");
						})
					}
					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("<div id='epinf'><div id='epl'></div></div>");

main();

setInterval(function () {
	main();
}, 30e3)