User:Joeytje50/Conquest.user.js

// ==UserScript== // @name          RuneScape Drop Logs // @description   Keep track of your drops easily // @include       *runescape.com* // @version       2.0 // ==/UserScript==

//Importing JQuery var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+");":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function{return execute(b)})}; loadAndExecute('https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js', function { //End importing JQuery

function setCookie( c_name, value, expiredays ) { var exdate = new Date; exdate.setDate( exdate.getDate + expiredays); document.cookie = c_name + "=" + escape(value) + ';path=/' + ( ( expiredays === null ) ? "" : ";expires=" + exdate.toGMTString ); } function getCookie( c_name ) { if ( document.cookie.length > 0 ) { var c_start = document.cookie.indexOf( c_name + "=" ) if ( c_start !== -1 ) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf( ";", c_start ); if ( c_end === -1 ) { c_end = document.cookie.length; }			return unescape( document.cookie.substring( c_start, c_end ) ); } 	}	return ""; }

function entertroops { $('#menu').html(' #menu td {margin:0px;padding:0px;} #menu table {border-spacing:0px;border-collapse:collapse;} #menu table td {border:1px solid black;text-align:center;} #menu input[name] {width:75px;margin:1px;text-align:center;} #menu {display:inline-block;} #menu input[type="submit"], #menu > div {float:right;margin-top:3.5em;display:block;} #menu th {padding:0px 3px;} #menu [name="selected"] {color:green;} '+	' ');

var inputs = document.conquest.getElementsByTagName('input'); var cookie = getCookie('owncqsetup') cookie = cookie.length?eval(cookie):false; for (var i=0;i<7 && cookie;i++) { inputs[i+1].value = cookie[i] } }

$(function {	$('#menu').prepend('Playing Conquest') })

function opencqform { entertroops $('#menu form.entertroops').submit(function {		var inputs = document.conquest.getElementsByTagName('input');		var own = [];		var other = [];		for (i=1;i<8;i++) {			if (parseInt(inputs[i].value)) {				own.push(parseInt(inputs[i].value)?parseInt(inputs[i].value):0);				other.push(parseInt(inputs[i+7].value)?parseInt(inputs[i+7].value):0);			}		}		cookie = '['+own.join(',')+']';		setCookie('owncqsetup', cookie, 5);		$(this).find('tr.you').html(' Killed: '+own[0]+'  '+own[1]+'  '+own[2]+'  '+own[3]+'  '+own[4]+'  '+own[5]+'  '+own[6]+' ')		$(this).find('tr.them').html(' 5  5  4  2  2  5  3  3  5 '+ ' '+(1000-25*other[0]-50*other[1]-75*other[2]-100*(other[3]+other[4]+other[5])-200*other[6])+' 0 ')		.before(' Battle cry  Stoicism  Regenerate  Bombard  Winds of Fate  Charge  Chastise  Vigilance  Shield Wall resources commands  ')		$('#menu input[type="submit"]').replaceWith('  <input value="End game" type="button"> ')		$(this).replaceWith($(this).html);

$('#menu .them button').each(function {			if (parseInt($(this).val.split(',')[1]) > parseInt($('#resources').html)) $(this).attr('disabled','disabled')		})

$('#menu .you button').click(function {			$('#commands').html(parseInt($('#commands').html)+parseInt($(this).val));			$(this).html(parseInt($(this).html) - 1);			if ($(this).html == '0') $(this).attr('disabled','disabled');		}); $('#menu .them button').click(function {			$('#commands').html(parseInt($('#commands').html) - parseInt($(this).val.split(',')[1]));			if (!$(this).is('[name="selected"]')) {				$('#resources').html(parseInt($('#resources').html) - parseInt($(this).val.split(',')[1]));				if ($(this).is('.windsoffate button')) {					if ($('.them button[disabled][title]').length == 1) {						$('.them button[disabled][title]').removeAttr('disabled').html(function {return $(this).val.split(',')[0]});					} else {						$('.them button[disabled][title]').attr({'data-disabled':'disabled', 'title':'This command is still recharging, but might be re'}).removeAttr('disabled');					}				}			}			$(this).attr({'name':'selected', 'title':'This command is still recharging', 'disabled':'disabled'})			$('#menu .them button:not([name="selected"])').each(function { if (parseInt($(this).val.split(',')[1]) > parseInt($('#resources').html)) $(this).attr('disabled','disabled') })		});		$('input[value="Next round"]').click(function {			$('#commands').html(parseInt($('#commands').html) + 25)			$('.them button[disabled][title], .them button[data-disabled][title]').each(function { if ($(this).html == '1') { $(this).html($(this).val.split(',')[0]).removeAttr('disabled').removeAttr('data-disabled').removeAttr('title'); } else { $(this).html(parseInt($(this).html) - 1); }			});		});		$('input[value="End game"]').click(entertroops) }); }

//Closing JQuery import })//End closing JQuery import