simsekcountr / eRepmatik Fighter

// ==UserScript==
// @name			eRepmatik Fighter
// @description			Automtically fights for you in Erepublik
// @include			http://erepublik.com/*
// @include			http://www.erepublik.com/*
// @include			http://www.erepublik.com/*/military/battlefield-new/*
// @include			https://www.erepublik.com/*/military/battlefield-new/*
// @include			*//www.erepublik.com/*/military/battlefield-new/*

// @copyright			ErepublikScripter
// @version			2
// @license			LGPL http://www.gnu.org/licenses/lgpl.html
// ==/UserScript==




var a = document.createElement('b');
a.href = 'javascript:;';
a.id = 'autofight_button';
if (/^https:\/\/(www\.e|e)republik.com\/([a-z]+)\/military\/battlefield-new\//.test(window.location.href)) {
  document.getElementById('pvp').appendChild(a);
  document.getElementById('autofight_button').setAttribute('style', 'position:absolute;left:10px; bottom:140px; z-index:500;');
  document.getElementById('autofight_button').innerHTML = 'eRepmatik Fight';
}

var a = document.createElement('b');
a.href = 'javascript:;';
a.id = 'autofight_button';
if (/^http:\/\/(www\.e|e)republik.com\/([a-z]+)\/military\/battlefield-new\//.test(window.location.href)) {
  document.getElementById('pvp').appendChild(a);
  document.getElementById('autofight_button').setAttribute('style', 'position:absolute;left:10px; bottom:140px; z-index:500;');
  document.getElementById('autofight_button').innerHTML = 'eRepmatik Fight';
}



var b = document.createElement('script');
b.type = 'text/javascript';
b.text = '$j(document).ready(function(){function fightBot(a) {if (a>0) {var b=122+Math.floor(Math.random()*111);var t=10+Math.floor(Math.random()*22);if ($j(\'#current_health\').html()==\'0\') {$j(\'#DailyConsumtionTrigger\').click();t+=100+Math.floor(Math.random()*11);}setTimeout(function(){$j(\'#fight_btn\').click();setTimeout(function(){fightBot(a-1);}, b);}, t);}}function startBot() {var a=prompt(\'Kaç Vuruş Yapmak İstiyorsun?\');if (a!==null && a!==\'\') {if (parseInt(a)>0) {fightBot(parseInt(a));}}}$j(\'#autofight_button\').click(function(){startBot();});});';
var d = document.getElementsByTagName('body');
d[0].appendChild(b);