Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Freak OW Helper
- // @namespace You
- // @version 2f
- // @date 24 May 10
- // @match *.outwar.com/*
- // @exclude *.outwar.com/myaccount*
- // @require http://code.jquery.com/jquery-latest.js
- // @grant GM_setClipboard
- // @grant GM_openInTab
- // ==/UserScript==
- var owServer = oServer(document.URL);
- var button = document.createElement('button');
- var doc = document;
- if (doc.URL.indexOf("raidattack.php") > -1) {
- var autoRaidDamage = true;
- var bHandler = true;
- var aHit = new Array();
- RaidDamage();
- } else if (doc.URL.indexOf("world") > -1) {
- // display room number in tab
- setInterval(function() { doc.title = "OW | Room: " + curRoom }, 100);
- }
- //var x = document.cookie.length-1;
- //window.alert(x);
- // page-switch memory
- $('#toolbar_uid').attr('onchange', '');
- $('#toolbar_uid').change(function() {
- var uid = $('#toolbar_uid').val();
- //var uid = document.getElementById('toolbar_uid').value;
- //var uid2 = document.cookie.split('ow_userid=')[1].split('')[0];
- if (uid > 0) {
- //$.cookie("ow_userid=", uid);
- //document.cookie = 'ow_userid=' + uid;
- if (window.location.search.length != 0) {
- if (window.location.search.indexOf('suid=') != -1) {
- window.location = window.location.href.replace(/suid=\d+/i, ('suid='+uid))
- } else {
- window.location = window.location.href + '&suid='+uid;
- };
- } else {
- window.location = window.location.pathname + '?suid='+uid;
- };
- // } else if (uid < 1) {
- } else {
- window.location = '/myaccount';
- };
- });
- function getCrewName (number) {
- var links = document.links;
- var tlink = 'http://' + oServer(doc.URL) + '.outwar.com/crew_raidsults';
- for(var l = 0; l < links.length; l++) {
- if(links[l].href.startsWith(tlink)) {
- var crewnameParts = links[l].textContent.split('\'')[0].split(' ');
- var crewname = '';
- for(var i = 1; i < crewnameParts.length; i++) {
- crewname += crewnameParts[i] + ' ';
- }
- return crewname;
- }
- }
- }
- if ( document.URL.indexOf("crew_profile") != -1 ) {
- if (doc && doc != null) {
- var crewname = getCrewName();
- var tables = doc.getElementsByTagName('table'); //fetching all the tabels
- for (var t = 0; t < tables.length; t++){ //running through all the tables
- if(tables[t].border >= '1' && crewname != 'Results ') { //getting the one that contains the crew members
- var rows = tables[t].getElementsByTagName('tr');
- for (var r = 0; r < rows.length; r++){ //running through all the rows
- var cells = rows[r].getElementsByTagName('td'); //fetching the cells of the current row
- if(cells[0].innerHTML == '<b>Rank</b>') {
- rows[r].innerHTML = rows[r].innerHTML + '<td><b> </b></td>'
- } else {
- var link = rows[r].getElementsByTagName('a')[0].href;
- //rows[r].innerHTML = rows[r].innerHTML + '<td><a href="' + link + '" target="_blank"><img alt="Attack!" src="images/atk_player_icon.jpg" valign="center" border="0"></a></td><td><form method="POST" action="crew_hitlist" TARGET="_blank"><input type="hidden" name="hitname" value="' + cells[1].textContent + '"><input type="hidden" name="hitreason" value="' + crewname + '"><input NAME="addToHitlist" type="image" src="http://torax.outwar.com/images/rareicon.jpg" ></form></td>'
- rows[r].innerHTML = rows[r].innerHTML + '<td><a href="' + link + '" target="_blank" valign="center" border="0">Attack</a></td><td><form method="POST" action="crew_hitlist" TARGET="_blank"><input type="hidden" name="hitname" value="' + cells[1].textContent + '"><input type="hidden" name="hitreason" value="' + crewname + '"><input NAME="addToHitlist" type="image" src="http://torax.outwar.com/images/rareicon.jpg" ></form></td>'
- }
- }
- }
- }
- }
- }
- //if (doc.URL.indexOf("outwar") != -1) {
- var sessid = document.cookie.split('rg_sess_id=')[1].split(';')[0];
- var btn1 = document.createElement("button");
- btn1.appendChild(document.createTextNode("COPY RG_SESS_ID"));
- btn1.setAttribute('title', sessid);
- btn1.setAttribute('style', 'font-family: "Verdana" !important; background-color: inherit; width:160px; padding:4px; margin-bottom: 1px; color: #FFF !important; font-weight:bold !important; border:1px; cursor: pointer;');
- //btn1.addEventListener("click", function() { alert("RG_SESS_ID Copied to Clipboard")}, false);
- btn1.addEventListener('mouseover', function() {
- this.title = sessid
- }, false);
- btn1.addEventListener("click", function() {
- GM_setClipboard(sessid)
- }, false);
- $("div#accordian ul li").last().append("<li><hr color=#C50202></li>");
- $("div#accordian ul li").last().append(btn1);
- $("div#accordian ul li").last().append("<h3><a href='expchart'><font color=white><center>EXP CHART</center></font></a></h3>");
- $("div#accordian ul li").last().append("<h3><a href='crew_vault'><font color=white><center>CREW VAULT</center></font></a></h3>");
- $("div#accordian ul li").last().append("<h3><a href='crew_bossspawns'><font color=white><center>BOSS SPAWNS</center></font></a></h3>");
- $("div#accordian ul li").last().append("<li><hr color=#C50202></li>");
- //console.log(thediv.childNodes);
- if (doc.URL.indexOf("world") != -1) {
- //var thediv = doc.getElementById('accordian');
- var box = doc.createElement('LI');
- var linkme = doc.createElement('a');
- linkme.addEventListener("click", attackmobs, false);
- //linkme.setAttribute('title', "Attack all the mobs in this room");
- linkme.appendChild(doc.createTextNode('ATTACK ALL MOBS'));
- linkme.setAttribute('href', '#');
- linkme.setAttribute('style', 'font-family: "Verdana" !important; color: white !important; font-weight:bold !important; border:1px; cursor: pointer;');
- box.setAttribute('style', 'text-align: center; width: 160px; padding:4px;');
- box.appendChild(linkme);
- //thediv.insertBefore(box, thediv.childNodes[2]);
- $("div#accordian ul li").last().append(box);
- }
- if (window.location.href.indexOf("/world") > -1) {
- var searchForm = document.createElement('div');
- searchForm.setAttribute('id', 'search_form');
- searchForm.setAttribute('style', 'border: 1px solid #990000; font-family: "Verdana" !important; background-color: #990000 !important; width: 154px; padding: 2px !important; color: #FFF !important; font-weight:bold !important; cursor: pointer;');
- box.appendChild(searchForm);
- var searchInput = document.createElement('input');
- searchInput.setAttribute('size', '14');
- searchInput.setAttribute('type', 'text');
- searchInput.setAttribute('id', 'sPlayer');
- searchInput.setAttribute('style', 'font-family: "Verdana" !important; background-color: black; width: 99px; padding: 0px !important; margin: 1px !important; color: #FFF !important; font-weight:bold !important; cursor: default;');
- searchInput.addEventListener('click', killHandler, false);
- searchInput.addEventListener('blur', reviveHandler, false);
- searchInput.addEventListener('keypress', function(e) {
- if (e.keyCode == 13) {
- document.getElementById('search_button').click();
- }
- }, false);
- var searchSubmit = document.createElement('input');
- searchSubmit.setAttribute('type', 'button');
- searchSubmit.setAttribute('value', 'Search');
- searchSubmit.setAttribute('id', 'search_button');
- searchSubmit.setAttribute('style', 'color: #000 !important; background-color: gray; width: 50px; padding-top: 2px !important; cursor: pointer;');
- searchSubmit.addEventListener('click', goSearch, false);
- searchForm.appendChild(searchInput);
- //searchForm.appendChild(document.createElement('br'));
- searchForm.appendChild(searchSubmit);
- masterdiv.insertBefore(searchForm, masterdiv.lastChild);
- function goSearch() {
- var sPlayer = trim(document.getElementById('sPlayer').value);
- var owServer = oServer(document.URL);
- location.href = 'http://' + owServer + '.outwar.com/profile?transnick=' + sPlayer;
- }
- }
- // will probably trigger rate limit error now
- if ( document.URL.indexOf("crew_profile") > -1 ) {
- var link2 = document.createElement('a');
- link.addEventListener("click", crewprofileTabs, false);
- link.setAttribute('title',"Clicking this will open everyone's profile in tabs. It may take several minutes to load.");
- link.appendChild(document.createTextNode(' @'));
- link.setAttribute('href','#');
- link.setAttribute('style','color: orange; font-weight: bold; font-size: 10px;');
- var doc2 = document;
- if (doc2 && doc2 != null) {
- var maindiv = doc2.getElementsByTagName("td");
- var i2 = 0;
- for (i2; i2 < maindiv.length; i2++){
- if ( maindiv[i2].innerHTML.indexOf("Name") > -1 ) {
- maindiv[i2].appendChild(link2);
- }
- }
- }
- }
- function crewprofileTabs() {
- var doc = document;
- if (doc != null){
- var aLinks = doc.links;
- if (aLinks && aLinks != null && aLinks.length > 0 ){
- var i = 0;
- for (i; i < aLinks.length; i++){
- if ( oPage(aLinks[i].href, 'profile.php') == true ){
- GM_openInTab(aLinks[i].href, true);
- }
- }
- }
- }
- }
- // need to add time interval every 4ish tabs to avoid rate limit error
- function attackmobs() {
- // check we have document object
- if (doc != null){
- // get all links
- var aLinks = doc.links;
- // check
- if (aLinks && aLinks != null && aLinks.length > 0 ){
- // loop
- var i = 0
- for (i; i < aLinks.length; i++){
- // check
- if ( oPage(aLinks[i].href, 'somethingelse.php') == true ){
- // open new tab
- GM_openInTab(aLinks[i].href);
- }
- }
- }
- }
- }
- // error handling, return to earth
- //var owsrc = '/images/errorz.jpg',
- //imgs = doc.evaluate("//img[contains(@src, '"+owsrc+"')]",doc,null,6,null);
- //var e = imgs.snapshotLength-1
- //for(e; e >= 0; e--) {
- // location.href = 'http://' + owServer + '.outwar.com/world';
- //}
- // quest help - doesn't work right now
- //if (document.body.innerHTML.indexOf("They are in a lost section of the Foundry") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=14264&stepid=758&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("5 Dark Essences") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4045&stepid=438&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("Shadow Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4045&stepid=437&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("5 Holy Essences") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4043&stepid=442&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("Holy Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4043&stepid=441&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("5 Fiery Essence") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4042&stepid=448&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("Fire Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4042&stepid=447&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("5 Arcane Essences") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4044&stepid=440&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("Arcane Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4044&stepid=439&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("1 Flame-Scarred Ruby") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4041&stepid=444&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("Kinetic Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=4041&stepid=443&finish=1&userspawn=';
- //} else if (document.body.innerHTML.indexOf("purchase a potion") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=2160075&stepid=1512&userspawn=1';
- //} else {
- // if (document.body.innerHTML.indexOf("Kix Potion!") > -1) {
- // location.href = 'http://' + owServer + '.outwar.com/mob_talk.php?id=2160075&stepid=1509&finish=1&userspawn=1';
- // }
- //}
- //display passwords and security words on mouseover
- (function () {
- var inputs, input;
- inputs = document.evaluate('//input[@type="password"]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
- if (!inputs.snapshotLength) return;
- for (var i = 0; i < inputs.snapshotLength; i++) {
- input = inputs.snapshotItem(i);
- input.addEventListener('mouseover', function (event) {
- this.type = 'text';
- }, false);
- input.addEventListener('mouseout', function (event) {
- this.type = 'password';
- }, false);
- }
- })();
- // logout confirmation
- var links = document.getElementsByTagName('a');
- for (var x = 0; x < links.length; x++) {
- if (links[x].getAttribute('href') == '/?cmd=logout') {
- links[x].setAttribute('onclick', 'return confirm(\'Are you sure you want to Logout?\')')
- }
- }
- if (document.URL.indexOf("crew_invites") != -1) {
- document.forms[0].elements[0].focus();
- } else if (document.URL.indexOf("homepost") != -1) {
- document.forms[0].elements[0].focus();
- } else if (document.URL.indexOf("security_prompt") != -1) {
- document.forms[0].elements[1].focus();
- } else if (document.URL.indexOf("formraid") != -1) {
- document.forms[0].elements[0].value = 3;
- } else if (document.URL.indexOf("cast_skills") != -1) {
- if (document.forms.length > 0) {
- document.forms[0].elements[1].focus();
- }
- }
- // need to fix this
- // Shows Results Faster (exp gained and item)
- if (unsafeWindow.location.href.indexOf("/attack") != -1 ) {
- //var result_text = setTimeout("result_text.innerHTML='<b>"+unsafeWindow['battle_result']+"</b>'",0);
- //var result_text = setTimeout("result_text.innerHTML='<b>"+unsafeWindow.battle_result+"</b>'",0);
- var result_text = unsafeWindow.result_text;
- var battle_result = unsafeWindow.battle_result;
- if ( ( battle_result == null ) || ( battle_result == '' ) ) {
- battle_result = '';
- }
- battle_result = battle_result.replace(/\'/g,'\\\'');
- result_text.innerHTML="<b>"+battle_result+"</b>";
- }
- //if ( ( document.URL.indexOf("attack") != -1 ) && ( document.URL.indexOf("raidattack.php") == -1 ) ) {
- //setTimeout("result_text.innerHTML='<b>"+unsafeWindow['battle_result']+"</b>'",0);
- //result_text.innerHTML="<b>"+battle_result+"</b>";
- //result_text.innerHTML="<b>"+result_notice_window+"</b>";
- //}
- function killHandler () {
- bHandler = false;
- }
- function reviveHandler() {
- bHandler = true;
- }
- var oHandler = unsafeWindow.handler;
- function myHandler (e) {
- if ( ( bHandler ) && ( oHandler != null ) ) {
- oHandler(e);
- }
- }
- unsafeWindow.onkeypress = myHandler;
- function oProfileId(doc) {
- var myregexp = /allies.php.uid=(\w+)/;
- var links = doc.links;
- var i = 0;
- for (i; i < links.length; i++) {
- var match = myregexp.exec(links[i]);
- if (match != null) {
- var id = match[1];
- return id;
- }
- }
- }
- function numberWithCommas(x) {
- return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- }
- function roundUp(num, precision) {
- precision = Math.pow(10, precision)
- return Math.ceil(num * precision) / precision
- }
- function RaidDamage() {
- var damage = 0;
- var newDamage = 0;
- var firstSpan = null;
- var lastSpan = null;
- if (doc) {
- var spans = doc.getElementsByTagName('span');
- if (spans && spans.length > 0) {
- var firstwithout = -1;
- for (var i = 0; i < spans.length; i++) {
- if (spans[i].hasAttribute('id')) {
- if (left(spans[i].getAttribute('id'), 8) == 'message_') {
- spans[i].setAttribute('style', 'visibility: visible');
- if (autoRaidDamage == true) {
- if (spans[i].parentNode.hasAttribute('rowspan') && spans[i].parentNode.hasAttribute('align')) {
- if (firstSpan == null) {
- firstSpan = spans[i];
- }
- lastSpan = spans[i];
- }
- var b = spans[i].getElementsByTagName('b');
- if (b && b.length == 1) {
- var fonts = b[0].getElementsByTagName('font');
- if (fonts && fonts.length >= 1) {
- newDamage = trim(fonts[fonts.length - 1].innerHTML);
- newDamage = newDamage.replace(/,/g, "");
- if (isNumeric(newDamage) == true) {
- damage += parseInt(newDamage);
- }
- }
- } else if (firstwithout == -1) {
- firstwithout = spans[i + 1];
- }
- }
- }
- }
- }
- if (autoRaidDamage == true && damage > 0 && lastSpan != null && firstSpan != null) {
- var newImage = doc.createElement('img');
- var newTable = doc.createElement('table');
- var newTr = doc.createElement('tr');
- var newTd = doc.createElement('td');
- var newLink = doc.createElement('a');
- var resultTd = doc.createElement('td');
- var resultTr = doc.createElement('tr');
- //newImage.setAttribute('src', 'images/spacer.gif');
- //newImage.setAttribute('height', '20');
- //newImage.setAttribute('width', '1');
- //lastSpan.parentNode.appendChild(newImage);
- //find last percentage on page
- var percentage = $('td:contains("%"):last').map(function(){return $.trim($(this).text());}).get();
- var integer = parseInt(percentage, 10);
- var result1 = (integer / 100) * damage;
- var result = roundUp(result1, 1)
- //window.alert(numberWithCommas(result));
- if (document.getElementsByTagName('center')[1].innerHTML.indexOf(' has won!') != -1) {
- resultTd.innerHTML = '<b><font color="#00FF00">WIN</font></b>';
- } else {
- resultTd.innerHTML = '<b><font color="#C50202">LOST </font></b><font color="#ffffff">('+percentage+') | '+numberWithCommas(result)+'</font>';
- };
- resultTd.setAttribute('style', 'font-family: "Verdana";text-align:center;font-size:13px;');
- newTd.innerHTML = 'Total Damage: ' + numberWithCommas(damage);
- resultTr.appendChild(resultTd);
- //newTd.setAttribute('style', 'padding-left:10px;color:orange;');
- newTd.setAttribute('style', 'font-family: "Verdana"; text-align: center; color: #FFFFFF; font-weight:normal; font-size: 13px;');
- newTr.appendChild(newTd);
- newTable.setAttribute('width', '268');
- newTable.setAttribute('height', '10');
- newTable.setAttribute('style', 'border: 2px solid black; background: #2b2b2b; border-radius: 10px;');
- newTable.appendChild(resultTr);
- newTable.appendChild(newTr);
- newLink.setAttribute('href', '#');
- newLink.innerHTML = 'Back to Top';
- lastSpan.parentNode.appendChild(newTable);
- lastSpan.parentNode.appendChild(newImage.cloneNode(true));
- lastSpan.parentNode.appendChild(newLink);
- firstSpan.parentNode.insertBefore(newTable.cloneNode(true), firstSpan);
- firstSpan.parentNode.insertBefore(newImage.cloneNode(true), firstSpan);
- var sTable = doc.createElement('table');
- var sTr = doc.createElement('tr');
- var sTd = doc.createElement('td');
- sTd.innerHtml = ' ';
- sTd.setAttribute('style', 'border:0px;');
- sTr.appendChild(sTd);
- sTable.setAttribute('style', 'border:0px;');
- sTable.setAttribute('height', '28');
- sTable.appendChild(sTr);
- firstwithout.parentNode.insertBefore(sTable.cloneNode(true), firstwithout);
- firstwithout.parentNode.insertBefore(newImage.cloneNode(true), firstwithout);
- /*// create a box for raid results
- var box = document.createElement('div');
- box.id = 'center_div';
- box.textContent = 'Total Damage: ' + damage;
- box.setAttribute('style', 'position:fixed; top:'+window.innerHeight/2+'px; left:'+window.innerWidth/2+'px; height: 50px; width: 200px; border:2px solid #990000; background:#000000; color:#ffffff; padding:20px; -moz-border-radius:4px; -moz-appearance:none;');
- document.body.appendChild(box);
- alignCenter('center_div');
- window.addEventListener('resize', function(e){alignCenter('center_div')}, false);*/
- }
- }
- }
- }
- //$('table td:contains("%"):last').css('color','red');
- //document.body.innerHTML= document.body.innerHTML.replace(/RAGE/g, function(m){
- // return '<span style="color:red">'+m+'</span>'
- //});
- //var elmDeleted = document.getElementById("questhelper");
- //elmDeleted.parentNode.removeChild(elmDeleted);
- //var elmDeleted2 = document.getElementById("foot_right");
- //elmDeleted2.parentNode.removeChild(elmDeleted2);
- function left(str, n) {
- if (n <= 0) {
- return "";
- }
- if (n > String(str).length) {
- return str;
- } else {
- return String(str).substring(0, n);
- }
- }
- function trim(str) {
- return str.replace(/^\s*|\s*$/g, "");
- }
- function isNumeric(sText) {
- var ValidChars = "0123456789";
- var Char;
- var i = 0;
- for (i; i < sText.length; i++) {
- Char = sText.charAt(i);
- if (ValidChars.indexOf(Char) == -1) {
- return false;
- }
- }
- return true;
- }
- function oPage(vURL, vPage) {
- var regex = new RegExp("^https?://(torax|sigil|www)\.outwar\.com/(" + vPage + ")");
- var result = regex.exec(vURL);
- if (result != null) {
- if (result.length == 3) {
- if (result[2] == vPage) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- function oServer(vURL) {
- var regex = new RegExp("^https?://(torax|sigil|www)\.outwar\.com/");
- var result = regex.exec(vURL);
- if (result != null) {
- if (result.length == 2) {
- return result[1];
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement