Nexus Clash Interface Tweaks

Various Tweaks to the Nexus Clash Browser Game Interface

  1. // ==UserScript==
  2. // @name Nexus Clash Interface Tweaks
  3. // @namespace http://userscripts.org/users/125692
  4. // @description Various Tweaks to the Nexus Clash Browser Game Interface
  5. // @include http://nexusclash.com/modules.php?name=Game*
  6. // @include http://www.nexusclash.com/modules.php?name=Game*
  7. // @exclude http://nexusclash.com/modules.php?name=Game&op=disconnect
  8. // @exclude http://www.nexusclash.com/modules.php?name=Game&op=disconnect
  9. // @grant none
  10. // @version 1.6
  11. // ==/UserScript==
  12. //for nexus clash. this script
  13. // -adds a checkbox for each drop button and disables the button until the checkbox is checked.
  14. // -adds a checkbox for each skill button and disables the button until the checkbox is checked.
  15. // -adds a checkbox for leave faction button and disables the button until the checkbox is checked.
  16. // -make the message box a bit bigger
  17. // -colours hits red and misses pink.
  18. // -1.5 added make message box bigger on login if there are lotsa messages
  19. //1.5.2 -bugfix for lock picking.
  20. //1.5.3 -hide all clothing by default
  21. //1.5.4 -bugfix no hiding armour (any wearable items with weight).
  22. //1.5.5 -made inventory buttons not mess with inventory width
  23. // -hide clothing by default
  24. //1.5.5 -new mouse over for inventory
  25. //1.5.7 -Removed neutral icon replacement.
  26. //1.5.8 -own name highlighted
  27. //1.5.9 -added enchanting highlighting
  28. //1.6 -yet more highlighting
  29. // -fix door repair bug.
  30. (function() {
  31.  
  32. function addGlobalStyle(css) {
  33. var head, style;
  34. head = document.getElementsByTagName('head')[0];
  35. if (!head) { return; }
  36. style = document.createElement('style');
  37. style.type = 'text/css';
  38. style.innerHTML = css;
  39. head.appendChild(style);
  40. }
  41. function addNamedGlobalStyle(css,idname) {
  42. var head, style;
  43. head = document.getElementsByTagName('head')[0];
  44. if (!head) { return; }
  45. style = document.createElement('style');
  46. style.id=idname;
  47. style.type = 'text/css';
  48. style.innerHTML = css;
  49. head.appendChild(style);
  50. }
  51. // got this off http://stackoverflow.com/questions/4009756/how-to-count-string-occurrence-in-string
  52. var timesCharExist=function(x,c){var t=0,l=0,c=c+'';while(l=x.indexOf(c,l)+1)++t;return t;};
  53. //Just some constants
  54. var SMWARNINGCOLOUR="red"; //colour for Sorcerers Might Status. To try and stop me wasting FAKs.
  55. var LOWAPWARNINGCOLOUR="gold"; //colour for background of headings to signify low ap.
  56. var LOWHPWARNINGCOLOUR="crimson"; //colour for background of heading when you have died (or are about to.)
  57. var LOWHPBACKGROUNDCOLOUR="crimson"; //colour for backgound of text of AP and HP when low.
  58. LOWAPBACKGROUNDCOLOUR="#fa8000";
  59. //AND ADD SOME STYLES
  60. //drop item checkbox
  61. //addNamedGlobalStyle('table[align="right"]>tbody>tr:nth-of-type(3){visibility: hidden;}','magehideinventory');
  62. addGlobalStyle('td.Magedropcell {position:relative;white-space: nowrap !important;overflow-x:visible;}\
  63. td.MageNoWrap {white-space: nowrap !important;overflow-x:visible;}\
  64. .magedropboxdiv{position:absolute;padding:0px;}\
  65. form.magedropcheckbox{position:relative;padding:0px 3px 0px 0px;top:-5px;vertical-align:middle;}\
  66. a.magesmallerdroptext{font-size:smaller;}\
  67. a.MageHide { display: none ! important; }\
  68. table[align="right"]>tbody>tr:nth-of-type(3) tr:hover{background-color:#ddddff!important;}');
  69. /*
  70. table[align="right"]>tbody>tr:nth-of-type(3) tr:nth-child(odd){background-color:#eeeeee;}\
  71. table[align="right"]>tbody>tr:nth-of-type(3) tr:nth-child(even){background-color:#ffffff;}*/
  72. //hide clothing
  73. addGlobalStyle(".mageshowclothspan{font-size:smaller;position:relative;right:0px;top:-5px;z-index:1;display:inline;}\
  74. .mageshowclothboxspan{position:relative;right:-40px;top:-25px;overflow-x:visible;display:inline;}\
  75. tr.MageWearable{font-size:smaller;color:090909;}\
  76. th.MageClothHeader{overflow:visible;position:absolute;font-size:.5em;display:inline;height:10px; }");
  77.  
  78. //this one is named so can be toggled.
  79. addNamedGlobalStyle("tr.MageWearableHIDE{display:none;}","mageshowclothing");
  80.  
  81. //health bars
  82. addGlobalStyle("td.MageHealthBar {background-repeat:no-repeat;background-position:left bottom;\
  83. margin-bottom:0px;position:relative;top:-10px;\
  84. background-image:url(data:image/gif;base64,R0lGODlhAQAFAIABAACZAP%2F%2F%2FywAAAAAAQAFAAACAoRdADs%3D);} \
  85. td.MageHealthBar2 {background-repeat:no-repeat;background-position:left bottom; margin-bottom:0px;\
  86. background-image:url(data:image/gif;base64,R0lGODdhAQAFAIACAAAAAP8AACwAAAAAAQAFAEACAoxdADs=);}");
  87. /*addGlobalStyle(".bar{line-height=:1px;height:5px;display:inline-block;margin: 0 0 0 0;padding: 0 0 0 0;position:absolute;top:20px;#bottom:1px;background-color:#ff0000;left:0px;} \
  88. .bar2{line-height=:1px;height:5px;display:inline-block;margin: 0 0 0 0;padding: 0 0 0 0;position:absolute;top:20px;#bottom:1px;background-color:#00ff00;left:0px;}");*/
  89.  
  90. //addGlobalStyle('.numberdiv{display:inline-block;padding:0 0 0 0;margin: 0 0 0 0;width:20px;position:relative;}');
  91.  
  92. //style for hp ap mp bars
  93. addGlobalStyle('img.MageBarBck {position:absolute;left:1;top: 18;display:inline;z-index:0}\
  94. img.MageBar {position:absolute;left:1;top: 18;display:inline;z-index:1}');
  95.  
  96. //styles for pet messages
  97. /*addGlobalStyle('div.MagePetHit {font-size:smaller;color:lightcoral ! important;padding-left:4em;}');
  98. addGlobalStyle('div.MagePetHitMe {font-size:smaller;color:red ! important;padding-left:4em;}');
  99. addGlobalStyle('div.MagePetKill {font-size:smaller;color:crimson;padding-left:4em;}');
  100. addGlobalStyle('div.MagePetMiss {font-size:smaller;color:#CAA083;padding-left:4em;}');
  101. addGlobalStyle('div.MagePetHealOthers {font-size:smaller;color:5050aa;padding-left:4em;}');
  102. addGlobalStyle('div.MagePetHealMe {font-size:smaller;color:0808aa;padding-left:4em;}');
  103. addGlobalStyle('div.MagePetRejuv {font-size:smaller;color:aa50aa;padding-left:4em;}');
  104. addGlobalStyle('div.MagePetDespawn {font-size:smaller;color:ff8000;padding-left:4em;}');*/
  105. addGlobalStyle('div.MagePetHit {font-size:smaller;color:lightcoral ! important;padding-left:4em;} \
  106. div.MagePetHitMe {font-size:smaller;color:red ! important;padding-left:4em;} \
  107. div.MagePetKill {font-size:smaller;color:crimson;padding-left:4em;} \
  108. div.MagePetMiss {font-size:smaller;color:#CAA083;padding-left:4em;} \
  109. div.MagePetHealOthers {font-size:smaller;color:5050aa;padding-left:4em;} \
  110. div.MagePetHealMe {font-size:smaller;color:0808aa;padding-left:4em;} \
  111. div.MagePetRejuv {font-size:smaller;color:aa50aa;padding-left:4em;} \
  112. div.MagePetDespawn {font-size:smaller;color:ff8000;padding-left:4em;}');
  113. //styles for player attack messages
  114. addGlobalStyle('div.MageAttackHit {color:red ! important;}\
  115. div.MageAttackMiss {color:deeppink;}\
  116. div.MageAttacked {color:red;font-weight:600}\
  117. div.MageDoorRepair {font-size:smaller;padding-left:4em;} \
  118. div.MageDoorKill {font-size:smaller;padding-left:4em;}');
  119. //environmental damage
  120. addGlobalStyle('div.MageAttackedbyEnvironment {color:red;font-weight:100}');
  121. //player is healed
  122. addGlobalStyle('div.MageHealed {color:0808aa;}');
  123. //style for achievement messages
  124. addGlobalStyle('div.MageAchievement {font-size:smaller;padding-left:4em;}\
  125. span.MageAchievementColour {color:aa0000;}\
  126. div.MageSpeech {color:dodgerblue;}\
  127. div.MageAction {color:aaaaff;}\
  128. div.MageWhisper{color:MediumOrchid;}\
  129. span.MageMe{color:darkblue;}\
  130. div.MageReceivedSomething{color:ff8040;}\
  131. div.MageGaveSomething{color:ff9045;}\
  132. div.MageCraft{color:8d4f9d;}\
  133. div.MageSearchNothing{color:8c8c55;}\
  134. div.MageSearchYay{color:8c8c00;}\
  135. span.MageShadowText{color:e00f0f;}\
  136. span.MageNameHighlight{background-color:ffff70;}');
  137. //this copied off the web
  138. //http://stackoverflow.com/questions/9447950/script-to-save-settings
  139. // for chrome
  140. /*if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  141. this.GM_getValue=function (key,def) {
  142. return localStorage[key] || def;
  143. };
  144. this.GM_setValue=function (key,value) {
  145. return localStorage[key]=value;
  146. };
  147. this.GM_deleteValue=function (key) {
  148. return delete localStorage[key];
  149. };
  150. };*/
  151.  
  152. var newbox;
  153. var acell;
  154. var loc=location+'';//lol cludgy
  155.  
  156. /*
  157. var isstart = document.evaluate(
  158. "//h2[starts-with(.,'Welcome back to Nexus Clash!')]",
  159. document,
  160. null,
  161. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  162. null
  163. );
  164.  
  165. if (isstart.snapshotLength == 1) {
  166. //we on start screen.
  167. //Store max ap/hp/mp values.
  168. var charlinks = document.evaluate(
  169. "//a[starts-with(@href,'modules.php?name=Game&op=character&id=')]",
  170. document,
  171. null,
  172. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  173. null );
  174. //charlinks.snapshotLength; //find<th>Character</th>
  175. var charid;
  176. var charmaxhp=50;
  177. var charmaxap=50;
  178. var charmaxmp=30;
  179. if (charlinks.snapshotLength > 1) {//found some charlinks
  180. var charlink=0;
  181. for (i=0;charlink=charlinks.snapshotItem(i);i++){
  182. //alert(i);
  183. charid=charlink.href.match(/id=(\d+)/)[1];
  184. charlink=charlink.parentNode.nextElementSibling.nextElementSibling;
  185. charmaxap=charlink.textContent.match(/\/(\d+)/)[1];
  186. charlink=charlink.nextElementSibling;
  187. charmaxhp=charlink.textContent.match(/\/(\d+)/)[1];
  188. charlink=charlink.nextElementSibling;
  189. charmaxmp=charlink.textContent.match(/\/(\d+)/)[1];
  190. //now store em away
  191. GM_setValue("maxap"+charid,charmaxap);
  192. GM_setValue("maxhp"+charid,charmaxhp);
  193. GM_setValue("maxmp"+charid,charmaxmp);
  194. }
  195. }
  196. return; //as that is all we want to do as none of the other tweaks apply on the start screen
  197. }*/
  198.  
  199.  
  200.  
  201.  
  202.  
  203. //##############################################################################################################
  204. //tweak whatever the count is now. 12 I suppose. BUT THIS ONE HAS TO GO FIRST.
  205. //AS replacing HTML fubars eventlisteners
  206. //highlight shadow text
  207. //The occasional shadow can be glimpsed moving in the windows
  208. if(document.getElementById("CharacterInfo")){
  209. var elementtosearch=document.getElementById("CharacterInfo").parentNode;
  210. elementtosearch.innerHTML=elementtosearch.innerHTML.replace(/(There are several shadows moving in the windows|The occasional shadow can be glimpsed moving in the windows)/,"<span class='MageShadowText'>$1</span>")
  211. }
  212.  
  213.  
  214. //##############################################################################################################
  215. //TWEAK 1 - Drop Item Button Safeties
  216. //if (loc.match(/buyskills/)){
  217. //do the item drop first by assuming we are on the right page and just looking for things with the item_drop class
  218. var elementsDropButtons = document.getElementsByClassName('item_drop');
  219. if(elementsDropButtons.length>0){//skip if we have none
  220. var elementDropButton;
  221. var rchange=function(e) {
  222. var targetbutton=e.target.parentNode.previousElementSibling;//button should be next element
  223. if(e.target.checked){
  224. //targetbutton.style.display='inline';
  225. targetbutton.style.visibility='visible';
  226. }
  227. else{
  228. //targetbutton.style.display='None';
  229. targetbutton.style.visibility='hidden';
  230. }
  231. }
  232. for (i=0;i<elementsDropButtons.length;i++){
  233. elementDropButton=elementsDropButtons[i];
  234. if (!elementDropButton.hasAttribute('mageconfirmflag')){//see if flag not set
  235. elementDropButton.setAttribute('mageconfirmflag',1);//set flag
  236. //elementDropButton.className+=" magesmallerdroptext";
  237. newbox=document.createElement('input');
  238. newboxdiv=document.createElement('span');//the containing div
  239. newboxdiv.className="magedropboxdiv";
  240. newbox.type='checkbox';
  241. newbox.checked=false;
  242. newbox.className='magedropcheckbox';
  243. newbox.addEventListener("click",rchange,false);
  244. acell=elementDropButton.parentNode;
  245. acell.className='Magedropcell';//set class for nowrap so doesn't fubar page
  246. //acell.align='left';
  247. //newboxdiv.insertBefore(newbox,newboxdiv.firstChild);
  248. newboxdiv.insertBefore(newbox,null);
  249. //newboxdiv.appendChild(newbox);
  250. acell.insertBefore(newboxdiv,elementDropButton.nextElementSibling);
  251. //elementDropButton.style.display='None';
  252. elementDropButton.style.visibility='hidden';
  253. }
  254. }
  255. }
  256. //TWEAK hide clothing
  257. //and while we are at it have a button to hide all the bloody clothing.
  258. var inventoryheaders = document.evaluate(
  259. "//th[starts-with(.,'Item')]",
  260. document,
  261. null,
  262. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  263. null
  264. );
  265. if(inventoryheaders.snapshotLength>0){
  266. var inventoryheader=inventoryheaders.snapshotItem(0);//pick the first one
  267. //add a checkox to do the hide show.
  268. var showclothbox=document.createElement('input');
  269. var showclothspan=document.createElement('span');
  270. var showclothboxspan=document.createElement('div');
  271. showclothbox.type='checkbox';
  272. showclothbox.className='magedropcheckbox';
  273. showclothbox.checked=false;
  274. var rscbchange=function(e) {
  275. var clothing=document.getElementById('mageshowclothing');
  276. if(e.target.checked){
  277. clothing.disabled=true;
  278. }
  279. else{
  280. clothing.disabled=false;
  281. }
  282. }
  283. showclothbox.addEventListener("click",rscbchange,false);
  284. var targetheader=inventoryheader.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling;
  285. targetheader.className="MageClothHeader";//make the show clothing text small
  286. showclothspan.className="mageshowclothspan";
  287. showclothboxspan.className="mageshowclothboxspan";
  288. //use 2 spans. one with the text and one with the checkbox?
  289. showclothspan.textContent="Show Clothing";//add text after so it can overflow.
  290. showclothboxspan.insertBefore(showclothbox,showclothboxspan.firstChild);//put the checkbox in a span
  291. targetheader.insertBefore(showclothboxspan,targetheader.firstChild);
  292. targetheader.insertBefore(showclothspan,targetheader.firstChild);
  293. //now look at inventory for clothing items and add to them the new css classes
  294. //get the rows with clothing. (wearable and weightless)
  295. var inventoryclothing = document.evaluate(
  296. "//tr[td/a/text()='Wear' and td/text()=0]",
  297. inventoryheader.parentNode,
  298. null,
  299. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  300. null
  301. );
  302. if (inventoryclothing.snapshotLength>0){
  303. var usableitem=0;
  304. for (i=0;usableitem=inventoryclothing.snapshotItem(i);i++){
  305. usableitem.className="MageWearable MageWearableHIDE";
  306. }
  307. }
  308. //olderway of doing it
  309. /*var usableitems=document.getElementsByClassName("item_use");
  310. var usableitem=0;
  311. for (i=0;usableitem=usableitems[i];i++){
  312. if(usableitem.textContent=="Wear"&&usableitem.parentNode.nextElementSibling.nextElementSibling.textContent=='0'){
  313. usableitem.parentNode.parentNode.className="MageWearable MageWearableHIDE";
  314. }
  315. }
  316. */
  317. /*
  318. //right now whle we at inventory hide spellgem colours.
  319. var inventorygems = document.evaluate(
  320. "//tr[contains(td/text(),'Spellgem')]",
  321. inventoryheader.parentNode,
  322. null,
  323. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  324. null
  325. );
  326. if (inventorygems.snapshotLength>0){//we have spellgems
  327. //set title text to color. Remove colour and move them to bottom of inventory
  328. var inventorygemrow=0;
  329. for (i=0;inventorygemrow=inventorygems.snapshotItem(i);i++){
  330. inventorygemrow.firstElementChild.textContent=inventorygemrow.firstElementChild.textContent.replace(/.*(Spellgem.*)/,'$1');
  331. }
  332. }
  333. //fuck it crude. now we have removed colours. Search again for spellgem rows and return sorted?
  334.  
  335. var wornrow= document.evaluate(
  336. "//tr[th/text()='Worn']",
  337. inventoryheader.parentNode,
  338. null,
  339. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  340. null
  341. );
  342. if (wornrow.snapshotLength>0){
  343. wornrow=wornrow.snapshotItem(0);
  344. var inventorygemrowparent=inventoryheader.parentNode.parentNode;
  345. for (i=0;inventorygemrow=inventorygems.snapshotItem(i);i++){
  346. //inventorygemrowparent =inventorygemrow.parentNode;
  347. inventorygemrowparent.insertBefore(inventorygemrow,wornrow);
  348. }
  349. }
  350. */
  351. }
  352. //##############################################################################################################
  353. //TWEAK 2 - learn spell gem buttons safeties
  354. //now we do the spellgem learn buttons
  355. elementsDropButtons = document.getElementsByClassName('item_use');
  356. if(elementsDropButtons.length>0){
  357. // elementDropButton;
  358. var rchange=function(e) {
  359. var targetbutton=e.target.nextElementSibling;//button should be next element
  360. if(e.target.checked){
  361. //targetbutton.style.display='';
  362. targetbutton.style.visibility='visible';
  363. }
  364. else{
  365. //targetbutton.style.display='None';
  366. targetbutton.style.visibility='hidden';
  367. }
  368. }
  369. for (i=0;i<elementsDropButtons.length;i++){
  370. elementDropButton=elementsDropButtons[i];
  371. if (!elementDropButton.innerHTML.match(/Learn/)){
  372. continue;
  373. }
  374. if (!elementDropButton.hasAttribute('mageconfirmflag')){//see if flag not set
  375. elementDropButton.setAttribute('mageconfirmflag',1);//set flag
  376. newbox=document.createElement('input');
  377. newbox.type='checkbox';
  378. newbox.checked=false;
  379. newbox.addEventListener("click",rchange,false);
  380. acell=elementDropButton.parentNode;
  381. //acell.className='MageNoWrap';//set class for nowrap so doesn't fubar page
  382. //acell.align='center';
  383. acell.insertBefore(newbox,elementDropButton);
  384. //elementDropButton.style.display='None';
  385. elementDropButton.style.visibility='hidden';
  386. }
  387. }
  388. }
  389. /*//now we do the spellgem learn buttons
  390. elementsDropButtons = document.getElementsByClassName('item_use');
  391. elementDropButton;
  392. for (i=0;i<elementsDropButtons.length;i++){
  393. elementDropButton=elementsDropButtons[i];
  394. if (!elementDropButton.innerHTML.match(/Learn/)){
  395. continue;
  396. }
  397. if (!elementDropButton.hasAttribute('mageconfirmflag')){//see if flag not set
  398. elementDropButton.setAttribute('mageconfirmflag',1);//set flag
  399. newbox=document.createElement('input');
  400. newbox.type='checkbox';
  401. newbox.checked=false;
  402. var rchange=function(e) {
  403. var targetbutton=e.target.nextElementSibling;//button should be next element
  404. if(e.target.checked){
  405. //targetbutton.style.display='';
  406. targetbutton.style.visibility='visible';
  407. }
  408. else{
  409. //targetbutton.style.display='None';
  410. targetbutton.style.visibility='hidden';
  411. }
  412. }
  413. newbox.addEventListener("click",rchange,false);
  414. acell=elementDropButton.parentNode
  415. //acell.className='MageNoWrap';//set class for nowrap so doesn't fubar page
  416. acell.align='center';
  417. acell.insertBefore(newbox,elementDropButton);
  418. //elementDropButton.style.display='None';
  419. elementDropButton.style.visibility='hidden';
  420. }
  421. }
  422. */
  423.  
  424. //unhide inventory
  425.  
  426. addNamedGlobalStyle('table[align="right"]>tbody>tr:nth-of-type(3){visibility:visible!important;}','magehideinventory');
  427. //document.getElementById('magehideinventory').disabled=true;
  428.  
  429.  
  430.  
  431. //##############################################################################################################
  432. //TWEAK 3- craft button safety
  433. //and now we do craft button
  434. //elementsDropButtons = document.getElementsByClassName('item_use');
  435. var elementsCraftButtons = document.getElementsByTagName('input')//get all input
  436. var elementCraftButton;
  437. var rchange2=function(e) {
  438. //alert("running");
  439. var targetbutton=e.target.nextElementSibling;//button should be next element
  440. if(e.target.checked){
  441. //targetbutton.style.display='';
  442. //targetbutton.style.visibility='visible';
  443. targetbutton.disabled=false;
  444. }
  445. else{
  446. //targetbutton.style.display='None';
  447. //targetbutton.style.visibility='hidden';
  448. targetbutton.disabled=true;
  449. }
  450. }
  451. for (i=0;i<elementsCraftButtons.length;i++){
  452. elementCraftButton=elementsCraftButtons[i];
  453. if (elementCraftButton.type!="submit"||elementCraftButton.value!="Craft"){//but sometimes isn't
  454. continue;//well we tried to find it but couldn't so abort it all.
  455. }
  456. if (!elementCraftButton.hasAttribute('mageconfirmflag')){//see if flag not set
  457. elementCraftButton.setAttribute('mageconfirmflag',1);//set flag
  458. var craftbox=document.createElement('input');
  459. craftbox.type='checkbox';
  460. craftbox.checked=false;
  461. craftbox.addEventListener("click",rchange2,false);
  462. acell=elementCraftButton.parentNode;
  463. //acell.className='MageNoWrap';//set class for nowrap so doesn't fubar page
  464. //acell.align='center';
  465. acell.insertBefore(craftbox,elementCraftButton);
  466. //elementCraftButton.style.display='None';
  467. //elementCraftButton.style.visibility='hidden';
  468. elementCraftButton.disabled=true;
  469. }
  470. }
  471. //}
  472. //##############################################################################################################
  473. //TWEAK 4-learn skill buttons safeties
  474. //if on buy skills page;
  475. //var loc=location+'';//lol cludgy
  476. //well in any event check if we are on the buyskills page and add saftey boxs to skill buttons
  477. //if this works the above code really should have been avoided by having some kind of test i suppose.
  478. if (loc.match(/buyskills/)||loc.match(/executepurchase/)){
  479. var rchange=function(e) {
  480. var targetbutton=e.target.nextElementSibling;//button should be next element
  481. if(e.target.checked){
  482. //targetbutton.style.display='';
  483. //targetbutton.style.visibility='visible';
  484. targetbutton.disabled=false;
  485. }
  486. else{
  487. //targetbutton.style.display='None';
  488. //targetbutton.style.visibility='hidden';
  489. targetbutton.disabled=true;
  490. }
  491. }
  492. var elementsSkillButtons = document.getElementsByTagName('input')//get all input
  493. var elementSkillButton;
  494. for (i=0;i<elementsSkillButtons.length;i++){
  495. elementSkillButton=elementsSkillButtons[i];
  496. if (elementSkillButton.type!="submit"){//but sometimes isn't
  497. continue;//well we tried to find it but couldn't so abort it all.
  498. }
  499. if (!elementSkillButton.hasAttribute('mageconfirmflag')){//see if flag not set
  500. elementSkillButton.setAttribute('mageconfirmflag',1);//set flag
  501. //now check if we have a confirm button and if so make it red
  502. if (elementSkillButton.value.match(/Confirm/)){
  503. elementSkillButton.style.color='red'//make it red to hightlight it
  504. }//'Confirm (10 CP)'
  505. newbox=document.createElement('input');
  506. newbox.type='checkbox';
  507. newbox.checked=false;
  508. newbox.addEventListener("click",rchange,false);
  509. acell=elementSkillButton.parentNode;
  510. //acell.className='MageNoWrap';//set class for nowrap so doesn't fubar page
  511. //acell.align='left';
  512. acell.insertBefore(newbox,elementSkillButton);
  513. //elementDropButton.style.display='None';
  514. //elementDropButton.style.visibility='hidden';
  515. elementSkillButton.disabled=true;
  516. }
  517. }
  518. }
  519. //##############################################################################################################
  520. //TWEAK 5-leave faction button safety
  521. //or perhaps we are viewing the faction page
  522. else if (loc.match(/faction&do=view/)){//viewing faction page
  523. var elementsSkillButtons = document.getElementsByTagName('input')//get all input
  524. var elementSkillButton;
  525. var rchange=function(e) {
  526. var targetbutton=e.target.nextElementSibling;//button should be next element
  527. if(e.target.checked){
  528. targetbutton.disabled=false;
  529. }
  530. else{
  531. targetbutton.disabled=true;
  532. }
  533. }
  534. for (i=0;i<elementsSkillButtons.length;i++){
  535. elementSkillButton=elementsSkillButtons[i];
  536. if (elementSkillButton.type!="submit"){//but sometimes isn't
  537. continue;//well we tried to find it but couldn't so abort it all.
  538. }
  539. if (!elementSkillButton.hasAttribute('mageconfirmflag')){//see if flag not set
  540. elementSkillButton.setAttribute('mageconfirmflag',1);//set flag
  541. if (elementSkillButton.value=="Leave Faction"){//just do the one button here. very ineffiecent code i think
  542. newbox=document.createElement('input');
  543. newbox.type='checkbox';
  544. newbox.checked=false;
  545. newbox.addEventListener("click",rchange,false);
  546. acell=elementSkillButton.parentNode
  547. acell.insertBefore(newbox,elementSkillButton);
  548. elementSkillButton.disabled=true;
  549. }
  550. }
  551. }
  552. }
  553. //##############################################################################################################
  554. //TWEAK 6- revoke faction button
  555. //do the revoke faction button
  556. var factionbuttons= document.evaluate("//form[@name='stronghold']", document, null,
  557. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  558. if (factionbuttons.snapshotLength>0){//if we have a faction box
  559. var factionbutton=factionbuttons.snapshotItem(0).firstElementChild.nextElementSibling;
  560. if (factionbutton.type=="submit"){//but sometimes isn't
  561. if (!factionbutton.hasAttribute('mageconfirmflag')){//see if flag not set
  562. factionbutton.setAttribute('mageconfirmflag',1);//set flag
  563. if (factionbutton.value.slice(0,17)=="Revoke Stronghold"){//just do the one button here.
  564. //alert("doing it")
  565. var anewbox=document.createElement('input');
  566. anewbox.type='checkbox';
  567. anewbox.checked=false;
  568. var rchange=function(e) {
  569. var targetbutton=e.target.nextElementSibling;//button should be next element
  570. if(e.target.checked){
  571. targetbutton.disabled=false;
  572. }
  573. else{
  574. targetbutton.disabled=true;
  575. }
  576. }
  577. anewbox.addEventListener("click",rchange,false);
  578. acell=factionbutton.parentNode;
  579. acell.insertBefore(anewbox,factionbutton);
  580. factionbutton.disabled=true;
  581. }
  582. }
  583. }
  584. }
  585. //##############################################################################################################
  586. //TWEAK 7 Thin full health and mana bars
  587. var healthbarimages= document.evaluate("//img[@src='images/g/HealthBar_1.gif']", document, null,
  588. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  589. for (var i=0,item;item=healthbarimages.snapshotItem(i) ;i++ ){
  590. //item.hidden='true';
  591. item.width='2';
  592. }
  593. var manabarimages= document.evaluate("//img[@src='images/g/MagicBar_1.gif']", document, null,
  594. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  595. for (var i=0,item;item=manabarimages.snapshotItem(i) ;i++ ){
  596. //item.hidden='true';
  597. item.width='2';
  598. }
  599.  
  600. //##############################################################################################################
  601. //TWEAK 8 Color hits/misses (and make message box bigger and resizable)
  602. if(document.getElementById("Messages")){
  603. var messages=document.getElementById("Messages");
  604. if (!(messages.previousElementSibling.innerHTML.match(/This Week/))){//ensure we dont do this on log page
  605. //if we are loggin in and there is a long list of messages make the message box a tad bigger
  606. //the '|| []' in the length is to avoid error when for when the regex fails to match anything and is null
  607. //if((loc.match(/name=Game$/)) && ((messages.innerHTML.match(/^ -/) || []).length > 10)){
  608. if((loc.match(/name=Game(&op=connect)?$/)) && (timesCharExist(messages.innerHTML,"\n")>13)){
  609. messages.style.height="250px";
  610. }
  611. //messages.style.height="145px";//make the message box a bit bigger
  612. messages.style.resize = "vertical";//allow resizing
  613. }
  614. var alonglist=messages.innerHTML.split("\n");
  615. var charname=false;// name of character
  616. var charnameregexp;// regexp pf name of character
  617. var charlinks;//links that have char name
  618. if(loc.match('&op=character')){//we might be on the character page
  619. charlinks = document.evaluate(
  620. "//h1",
  621. document,
  622. null,
  623. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  624. null );
  625. if (charlinks.snapshotLength==1){
  626. charname=charlinks.snapshotItem(0).textContent;
  627. charnameregexp = new RegExp("("+charname+")", "gi");
  628. }
  629. }
  630. else{
  631. charlinks = document.evaluate(
  632. ".//a[starts-with(@href,'modules.php?name=Game&op=character&id=')]",
  633. document.getElementById("CharacterInfo"),
  634. null,
  635. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  636. null );
  637. if (charlinks.snapshotLength==1){
  638. charname=charlinks.snapshotItem(0).textContent;
  639. charnameregexp = new RegExp("("+charname+")", "gi");
  640. }
  641. }
  642. for (i=0;i<alonglist.length;i++){ //For each line
  643. //first check every string for the dreaded a(n) and fix them
  644. alonglist[i]=alonglist[i].replace(/( a)(\(?(n)\)?( [AEIOUaeiou])|\(?n\)?( [^AEIOUaeiou]))/g,'$1$3$4$5');
  645. //regex string for replacing a(n)
  646. //a.replace(/((a)\((n)\)( [AEIOUaeiou])|(a)\(()n\)( [^AEIOUaeiou]))/g,'$2$3$4$5$6$7')
  647.  
  648. //then fix dreaded double '' (not ") turning them into singles. to help with searching for quotes etc...
  649. alonglist[i]=alonglist[i].replace(/(\'\')/g,"'");//replace '' with '
  650. alonglist[i]=alonglist[i].replace(/(\\\')/g,"'");//I\'
  651. //in this bit we find name of character and highlight all instances of it.
  652. if(charname){
  653. alonglist[i]=alonglist[i].replace(charnameregexp,"<span class='MageNameHighlight'>$1</span>");
  654. }
  655. //You attack and hit
  656. if(alonglist[i].match(/(- (\(\d+ times\) )?You attack .* with your .* and hit for .* damage..*)<br>/)){
  657. alonglist[i]="<div class='MageAttackHit'>"+alonglist[i]+"</div>";//colour hits red
  658. }
  659. //You attack and miss
  660. else if(alonglist[i].match(/(- (\(\d+ times\) )?You attack .* with your .* and miss..*)<br>/)){
  661. alonglist[i]="<div class='MageAttackMiss'>"+alonglist[i]+"</div>";//colour misses deeppink
  662. }
  663. //You defend
  664. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* attacked you with .*)<br>/)){
  665. alonglist[i]="<div class='MageAttacked'>!"+alonglist[i].substr(1)+"</div>";
  666. }
  667. //door repair kill spam
  668. // - Kate Upton repaired the door! (2014-08-06 11:20:39).
  669. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* repaired the door!.*)<br>/)){
  670. alonglist[i]="<div class='MageDoorRepair'>!"+alonglist[i].substr(1)+"</div>";
  671. }
  672. //- Kate Upton destroyed the door! (2014-08-06 11:20:41).
  673. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* destroyed the door!.*)<br>/)){
  674. alonglist[i]="<div class='MageDoorKill'>!"+alonglist[i].substr(1)+"</div>";
  675. }
  676. //Environmental damage
  677. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* (Your action causes you to|You|you) take \d+ point(s)? of( \b[a-z]+\b)? damage(.|!)?.*)<br>/)){
  678. alonglist[i]="<div class='MageAttackedbyEnvironment'>!"+alonglist[i].substr(1)+"</div>";
  679. }
  680. //defiler poinson
  681. else if(alonglist[i].match(/-( (\(\d+ times\) )?( )?<em>The defiler poison coursing through your veins makes you feel as though your blood is on fire. ( )?Your action causes you to take \d+ damage..*)<br>/)){
  682. alonglist[i]="<div class='MageAttackedbyEnvironment'>!"+alonglist[i].substr(1)+"</div>";
  683. }
  684. //PET REJUVENATION
  685. //- Your pet, Judgemaster, has been rejuvenated. You spent 15 Magic Points. (2013-06-25 02:17:16).
  686. //FFS two spaces before 'You spent...'
  687. else if(alonglist[i].match(/(- (\(\d+ times\) )?Your pet, .* has been rejuvenated. You spent \d+ Magic Point.*)<br>/)){
  688. alonglist[i]="<div class='MagePetRejuv'>"+alonglist[i]+"</div>";
  689. }
  690. //Player is healed by pet
  691. //- Aethersprite, belonging to kiwimage, healed you. You gain 10 hit points. The poison affecting you has been cured. (2013-06-18 14:12:52).
  692. else if(alonglist[i].match(/(- (\(\d+ times\) )?.* belonging to .*, healed you. You gain \d+ hit point(s)?.*)<br>/)){
  693. alonglist[i]="<div class='MagePetHealMe'>"+alonglist[i]+"</div>";
  694. }
  695. //Player healed by will-o-wisp(possibly also wight)
  696. //- Will-O-Wisp, belonging to Mr Scavvy, has funneled life energy to you, healing you of 1 points of damage. (2013-06-25 02:38:02).
  697. else if(alonglist[i].match(/(- (\(\d+ times\) )?.* belonging to .*, has funneled life energy to you, healing you of \d+ points of damage.*)<br>/)){
  698. alonglist[i]="<div class='MagePetHealMe'>"+alonglist[i]+"</div>";
  699. }
  700. //PET HEAL OTHERS
  701. //- Aethersprite, belonging to kiwimage, healed German Shepherd for 10 hit points. (2013-06-18 07:44:32).
  702. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*, belonging to .*, healed .* for \d+ hit point.*)<br>/)){
  703. alonglist[i]="<div class='MagePetHealOthers'>"+alonglist[i]+"</div>";
  704. }
  705. //PETS ATTACK
  706. else if(alonglist[i].match(/(- (\(\d+ times\) )?Your pet .* and hit for .*)<br>/)){
  707. alonglist[i]="<div class='MagePetHit'>"+alonglist[i]+"</div>";
  708. }
  709. //being hit by others pets made slightly more important.(though if you seeing this you are probably dead.)
  710. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*, belonging to .* and hit for .*)<br>/)){
  711. alonglist[i]="<div class='MagePetHitMe'>!"+alonglist[i].substr(1)+"</div>";
  712. }
  713. else if(alonglist[i].match(/(- (\(\d+ times\) )?(Your pet |[^,].*, belonging to).*, killing them!.*)<br>/)){
  714. alonglist[i]="<div class='MagePetKill'>"+alonglist[i]+"</div>";
  715. }
  716. else if(alonglist[i].match(/(- (\(\d+ times\) )?(Your pet |[^,].*, belonging to).* and missed.*)<br>/)){
  717. alonglist[i]="<div class='MagePetMiss'>"+alonglist[i]+"</div>";
  718. }
  719. //roaming pets attack you
  720. // Shambling Zombie attacked you and hit for
  721. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* attacked you and hit for.*)<br>/)){
  722. alonglist[i]="<div class='MagePetHitMe'>!"+alonglist[i].substr(1)+"</div>";
  723. }
  724. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* attacked you and missed.*)<br>/)){
  725. alonglist[i]="<div class='MagePetMiss'>!"+alonglist[i].substr(1)+"</div>";
  726. }
  727. //others pets attacking
  728. else if(alonglist[i].match(/-( (\(\d+ times\) )?.* attacked your pet,.*and hit for .*)<br>/)){
  729. alonglist[i]="<div class='MagePetHit'}>!"+alonglist[i].substr(1)+"</div>";//colour pet getting hit bold red with exclamation mark
  730. }
  731. else if(alonglist[i].match(/(- (\(\d+ times\) )?.* attacked your pet,.* killing it!.*)<br>/)){
  732. alonglist[i]="<div class='MagePetKill'>"+alonglist[i]+"</div>";
  733. }
  734. else if(alonglist[i].match(/(- (\(\d+ times\) )?.* attacked .* killing it!.*)<br>/)){
  735. alonglist[i]="<div class='MagePetKill'>"+alonglist[i]+"</div>";//PET MESSAGES SEEM TO BE ODDLY BORKED IN COMPARISON TO OTHERS
  736. }
  737. else if(alonglist[i].match(/(- (\(\d+ times\) )?.* attacked your pet.* and missed.*)<br>/)){
  738. alonglist[i]="<div class='MagePetMiss'>"+alonglist[i]+"</div>";//NOTE NO COMMA FOR MISS MESSAGES!
  739. }
  740. //- Danny Noonan, a Ghoul, belonging to Mr Scavvy, was killed by a defensive aura projected by Mack Bolan! (2013-07-12 00:11:21).
  741. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*, belonging to .*, was killed by a defensive aura projected by .*)<br>/)){
  742. alonglist[i]="<div class='MagePetKill'>"+alonglist[i]+"</div>";
  743. }
  744. //PET DESPAWN
  745. // - Your pet Lightspawn, a Ghoul, has despawned. (2013-06-21 19:00:07).
  746. //- Aethersprite, belonging to kiwimage, has despawned. (2013-06-18 07:49:21).
  747. //- Ghoul has despawned.
  748. //- Smoke Porterhouse, a Ghoul has despawned. (2013-06-26 06:09:22).
  749. //ffs so many different ways of saying it. depending on if it was killed or AP'ed out or MP'ed out....
  750. else if(alonglist[i].match(/(- (\(\d+ times\) )?(Your pet .*|.*, belonging to .*,|.*, a .*|\b\w+\b|Will-O-Wisp) has despawned.*)<br>/)){
  751. alonglist[i]="<div class='MagePetDespawn'>"+alonglist[i]+"</div>";
  752. }
  753. //ACHIEVEMENTS
  754. else if(alonglist[i].match(/((- (\(\d+ times\) )?)<font color="#DD0000">(<b>.*<\/b>)<\/font>(.*))<br>/)){
  755. alonglist[i]=alonglist[i].replace(/((- (\(\d+ times\) )?)<font color="#DD0000">(<b>.*<\/b>)<\/font>(.*))<br>/,'<div class="MageAchievement">$2<span class="MageAchievementColour">$4</span>$5</div>');//center annoucements
  756. }
  757. //Reading -No change but look for it so we don't then hightlight book quotes as speech
  758. else if(alonglist[i].match(/(- (\(\d+ times\) )?You read the book.*)<br>/)){
  759. //alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  760. }
  761. //SPEECH
  762. else if(alonglist[i].match(/(- (\(\d+ times\) )?)([^,].*)( said, )(\".*)<br>/)){
  763. //alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  764. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)([^,].*) (said, )(\".*)<br>/,"<div class='MageSpeech'>$1 $3<span class='MageMe'> $4</span>$5</div>");
  765. }
  766. else if(alonglist[i].match(/(- (\(\d+ times\) )?)([^,].*)( whispered to you, saying).(\".*)<br>/)){
  767. //alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  768. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)([^,].*) (whispered to you, saying).(\".*)<br>/,"<div class='MageSpeech'>$1 $3<span class='MageMe'> $4, </span>$5</div>");
  769. }
  770. //BULLHORN!
  771. else if(alonglist[i].match(/(- (\(\d+ times\) )?).*(Someone used a bullhorn to say: )(\'.*\')(.*)<br>/)){
  772. //alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  773. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?).*(Someone used a bullhorn to say: )(\'.*\')(.*)<br>/,"<div class='MageSpeech'>$1<span class='MageMe'>$3</span>$4<span class='MageMe'>$5</span></div>");
  774. }
  775. else if(alonglist[i].match(/(- (\(\d+ times\) )?)(You say, )(\".*)<br>/)){
  776. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)(You say, )(\".*)<br>/,"<div class='MageSpeech'>$1<span class='MageMe'>$3</span>$4</div>");
  777. }
  778. else if(alonglist[i].match(/(- (\(\d+ times\) )?You whisper, \".*)<br>/)){
  779. //alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  780. //Due to wanting to make the you part black but still have the initial - blue doing it with a replace.
  781. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)(You whisper, )(\".*)<br>/,"<div class='MageSpeech'>$1<span class='MageMe'>$3</span>$4</div>");
  782. }
  783. else if(alonglist[i].match(/(- (\(\d+ times\) )?[^,].* (said|say), \".*)<br>/)){
  784. alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  785. }
  786. else if(alonglist[i].match(/(- (\(\d+ times\) )?[^,].* (whispered to you|whisper), saying \".*)<br>/)){
  787. alonglist[i]="<div class='MageSpeech'>"+alonglist[i]+"</div>";
  788. }
  789. //GIVENATION
  790. else if(alonglist[i].match(/-( (\(\d+ times\) )?[^,].* gave you a.*)<br>/)){
  791. alonglist[i]="<div class='MageReceivedSomething'>+"+alonglist[i].substr(1)+"</div>";
  792. }
  793. else if(alonglist[i].match(/-( (\(\d+ times\) )?You give your.*)<br>/)){
  794. alonglist[i]="<div class='MageGaveSomething'>-"+alonglist[i].substr(1)+"</div>";
  795. }
  796. //CRAFTING
  797. else if(alonglist[i].match(/(- (\(\d+ times\) )?You call upon your crafting skills.*)<br>/)){
  798. alonglist[i]="<div class='MageCraft'>"+alonglist[i]+"</div>";
  799. }
  800. //enchanting
  801. else if(alonglist[i].match(/(- (\(\d+ times\) )? You marshall your magical knowledge and focus your attention on suffusing the item with your chosen enchantment. After several moments, you step away from the item, having met with success. The enchantment has been woven into the item.*)<br>/)){
  802. alonglist[i]="<div class='MageCraft'>"+alonglist[i]+"</div>";
  803. }
  804. //SEARCHING
  805. else if(alonglist[i].match(/(- (\(\d+ times\) )?You search and find nothing.*)<br>/)){
  806. alonglist[i]="<div class='MageSearchNothing'>"+alonglist[i]+"</div>";
  807. }
  808. else if(alonglist[i].match(/(- (\(\d+ times\) )?You search and find a.*)<br>/)){
  809. alonglist[i]="<div class='MageSearchYay'>+"+alonglist[i].substr(1)+"</div>";
  810. }
  811. //HEALING You heal yourself and gain 10 hit points
  812. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*(You heal yourself and|healed you. You) gain \d+ hit point(s)?.*)<br>/)){
  813. alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  814. }
  815. //- You use the herb to heal Rachel Stone for 5 points of damage. You gain 5 experience points. They are now fully healed. (2013-07-01 12:35:31).
  816. //HEALING HERBS
  817. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*You use the .* to heal .* for \d+ point(s)? of damage?.*)<br>/)){
  818. alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  819. }
  820. //HEALING FAKS
  821. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*You heal .* for \d+ point(s)? of damage?.*)<br>/)){
  822. alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  823. }
  824. // healing surgury
  825. //You use your surgeon skills to tend to Immanent_Eschaton and heal them for 15 points of damage. You gain 15 experience points.
  826. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*You use your surgeon skills to tend to .* and heal them for \d+ point(s)? of damage?.*)<br>/)){
  827. alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  828. }
  829. //healing leeches
  830. //- You place a Stygian Bone Leech on the skin of Repth and it burrows into their flesh, healing them for 15 points of damage. You gain 6 experience points. (2015-10-21 02:11:13).
  831. else if(alonglist[i].match(/(- (\(\d+ times\) )?.*You place a Stygian Bone Leech on the skin of .* and it burrows into their flesh, healing them for \d+ point(s)? of damage?.*)<br>/)){
  832. alonglist[i]="<div class='MageHealed'>"+alonglist[i]+"</div>";
  833. }
  834. //EMOTES
  835. //fancy “ ”
  836. else if(alonglist[i].match(/(- (\(\d+ times\) )?)([^<>]*?)( \u201C.+\u201D)(.*)<br>/)){
  837. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)([^<>]*?)( \u201C.+\u201D)(.*)<br>/,"<div class='MageSpeech' >$1<span class='MageMe'>$3</span>$4<span class='MageMe'>$5</span></div>");
  838. }
  839. //then "
  840. else if(alonglist[i].match(/(- (\(\d+ times\) )?)(.*?)( \u0022.+\u0022)(.*)<br>/)){
  841. //alert(alonglist[i]);
  842. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)(.*?)( \u0022.+\u0022)(.*)<br>/,"<div class='MageSpeech' >$1<span class='MageMe'>$3</span>$4<span class='MageMe'>$5</span></div>");
  843. }
  844. //then '
  845. else if((alonglist[i].match(/(- (\(\d+ times\) )?)([^<>]*?)( \'.+\')([^<>]*)<br>/))&&!(alonglist[i].match(/(- (\(\d+ times\) )?)You read the book\..*<br>/))){
  846. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)([^<>]*?)( \'.+\')([^<>]*)<br>/,"<div class='MageSpeech' >$1<span class='MageMe'>$3</span>$4<span class='MageMe'>$5</span></div>");
  847. }
  848. //then fancy ‘ ’ unicode 2018 2019
  849. else if(alonglist[i].match(/(- (\(\d+ times\) )?)([^<>]*?)( \u2018.+\u2019)(.*)<br>/)){
  850. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)([^<>]*?)( \u2018.+\u2019)(.*)<br>/,"<div class='MageSpeech' >$1<span class='MageMe'>$3</span>$4<span class='MageMe'>$5</span></div>");
  851. }
  852. //try other catch fancy quotes
  853. else if(alonglist[i].match(/(- (\(\d+ times\) )?)(<.*>)(.*)( \u201C.+\u201D)(.*)<br>/)){
  854. alonglist[i]=alonglist[i].replace(/(- (\(\d+ times\) )?)(<.*>)(.*?)( \u201C.+\u201D)(.*)<br>/,"<div class='MageSpeech' >$1<span class='MageMe'>$3$4</span>$5<span class='MageMe'>$6</span></div>");
  855. }
  856. }
  857. messages.innerHTML=alonglist.join('');
  858. }
  859. //##############################################################################################################
  860. // TWEAK 9 Weapon boxes list raw dam/ap. Does not take into account soak.
  861. var weaponboxs= document.evaluate("//select[@name='attacking_with_item_id']", document, null,
  862. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  863. if (weaponboxs.snapshotLength>0){//if we have a weapon box
  864. var test, weaponboxoptions,keeper;
  865. var best=0;
  866. for (var j=0,item;item=weaponboxs.snapshotItem(j) ;j++ ){//for each weapons box
  867. weaponboxoptions=item.getElementsByTagName('option');
  868. for (i=0;i<weaponboxoptions.length;i++ ){ //for each option of the box
  869. test=weaponboxoptions[i].text.match(/(\d+) dmg[^0-9]*(-?\d+)% to hit$/) // extract the last 2 numbers
  870. if (test){
  871. //alert(""+test[1]+":"+test[2]);
  872. weaponboxoptions[i].text+= " (dam/ap:"+test[1]*Math.min(Math.max(test[2],1),99)/100+")";
  873. if (best<(test[1]*test[2])){
  874. best=test[1]*test[2];
  875. keeper=i;
  876. }
  877. }
  878. //alert(weaponboxoptions[i].innerHTML.);
  879. if(weaponboxoptions[i].text.match(/Double-Barrelled /)){
  880. weaponboxoptions[i].text=weaponboxoptions[i].text.replace(/Double-Barrelled /,"");
  881. }
  882. }
  883. //item.selectedIndex=keeper;
  884. }
  885. }
  886.  
  887. //##############################################################################################################
  888. // TWEAK 10 Hatchet is default item to pick up (throwing knifes,rocks alternative default)
  889. var pickupforms= document.evaluate("//form[@name='pickup']", document, null,
  890. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);//find the form with name=pickup
  891. if (pickupforms.snapshotLength==1){//We have one and only one candidate
  892. var test, pickupform,pickupbox;
  893. var best=0;
  894. var keeper=0;
  895. var hatchetkeeper=-1;
  896. var throwingknifekeeper=-1;
  897. var rockkeeper=-1;
  898. pickupform=pickupforms.snapshotItem(0);
  899. pickupbox=pickupform.lastElementChild;//select box is the second child of what should be two
  900. pickupboxoptions=pickupbox.getElementsByTagName('option');
  901. //doing it this way hoping its faster because less text comparing.
  902. for (i=0;i<pickupboxoptions.length;i++ ){ //for each option of the box
  903. test = pickupboxoptions[i].innerHTML;
  904. if (test=='Hatchet'){//we have a keeper
  905. hatchetkeeper=i;//so make it the default thing to pick up
  906. break;//can't do better so stop looking
  907. }
  908. if ((throwingknifekeeper==-1)&&test=='Throwing Knife'){
  909. throwingknifekeeper=i;
  910. }
  911. if ((rockkeeper==-1)&&test=='Rock'){
  912. rockkeeper=i;
  913. }
  914. }
  915. if (hatchetkeeper>-1){
  916. keeper=hatchetkeeper;
  917. }
  918. else if(throwingknifekeeper>-1){
  919. keeper=throwingknifekeeper;
  920. }
  921. else if(rockkeeper>-1){
  922. keeper=rockkeeper;
  923. }
  924. pickupbox.selectedIndex=keeper;
  925. }
  926.  
  927. //##############################################################################################################
  928. //Tweak 11 Higlight move buttons when ap<10
  929. if(document.getElementById("CharacterInfo")){
  930. var charinfodiv=document.getElementById("CharacterInfo");
  931. var charlinks = document.evaluate(
  932. ".//a[starts-with(@href,'modules.php?name=Game&op=character&id=')]",
  933. charinfodiv,
  934. null,
  935. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  936. null );
  937. /*
  938. var charid=0;
  939. if (charlinks.snapshotLength==1){
  940. charid=charlinks.snapshotItem(0).href.match(/id=(\d+)/)[1];
  941. }
  942. var charmax = new Array();
  943. charmax[0]=GM_getValue("maxap"+charid,0);
  944. charmax[1]=GM_getValue("maxhp"+charid,0);
  945. charmax[2]=GM_getValue("maxmp"+charid,0);
  946. */
  947. var firstfont=charinfodiv.getElementsByTagName("font")[0];
  948. var secondfont=charinfodiv.getElementsByTagName("font")[1];
  949. var thirdfont=charinfodiv.getElementsByTagName("font")[2];
  950.  
  951. /*if (charmax[0]&&charmax[1]&&charmax[2]){//only if all are true(ie we got a proper value)
  952.  
  953. for(i=0;i<3;i++){
  954. var anewspan=document.createElement('div');
  955. anewspan.className="numberdiv";
  956.  
  957. var font=charinfodiv.getElementsByTagName("font")[i];//get font
  958. charstat=font.innerHTML.match(/\d+/); //get ap/hp/mp
  959. var reddiv=document.createElement('div');
  960. reddiv.style.width='20px';
  961. reddiv.className="bar";
  962. if(i==1){
  963. reddiv.title=charstat+"/"+charmax[i]+" Need "+ (Number(charmax[i])-Number(charstat))+"hp healed";}
  964. else{
  965. reddiv.title = charstat+"/"+charmax[i]+" Full in "+
  966. (Number(charmax[i])-Number(charstat))/4+" hours";
  967. }
  968. var greendiv=document.createElement('div');
  969. var greenwidth=parseInt(20*(Number(charstat)/Number(charmax[i])));
  970. greendiv.className="bar2";
  971. greendiv.style.width=""+greenwidth+"px";//to make out of 20 as int;
  972. greendiv.title=charstat+"/"+charmax[i];
  973.  
  974. var firstcell=font.parentNode;
  975. if(i==0){//first time is nested deeper
  976. firstcell=font.parentNode.parentNode;
  977. }
  978. firstcell.width='20px';
  979. anewspan.insertBefore(greendiv,anewspan.firstChild);//put img in span
  980. anewspan.insertBefore(reddiv,anewspan.firstChild);//put img in span
  981. anewspan.insertBefore(font,anewspan.firstChild);//move the text into the new span
  982. firstcell.insertBefore(anewspan,firstcell.firstChild);//put span in table cell
  983. }
  984. }*/
  985. if(Number(secondfont.innerHTML.match(/\d+/))<20){
  986. //secondfont.parentNode.parentNode.style.backgroundColor=LOWHPBACKGROUNDCOLOUR;//set the ap to orange color
  987. secondfont.parentNode.style.border="3px solid "+LOWHPBACKGROUNDCOLOUR;
  988. secondfont.parentNode.parentNode.parentNode.parentNode.style.border="2px solid "+LOWHPBACKGROUNDCOLOUR;
  989. //secondfont.style.color='black';//set the HP text to black so it's not red on red
  990. //secondfont.style.fontWeight=900;
  991. secondfont.parentNode.parentNode.title="LOW HEALTH";
  992. //also color alll the pane titles gold so make sure waring is noticed.
  993. var panetitles=document.getElementsByClassName("panetitle");
  994. for (var i=0,temp=0;temp=panetitles[i] ;i++ ){
  995. temp.style.color=LOWHPWARNINGCOLOUR;
  996. temp.title='LOW HEALTH';
  997. }
  998. }
  999. else if(Number(firstfont.innerHTML.match(/\d+/))<10){
  1000. //firstfont.parentNode.parentNode.style.backgroundColor=LOWHPBACKGROUNDCOLOUR;//set the ap to orange color
  1001. firstfont.parentNode.parentNode.style.border="1px solid "+LOWAPBACKGROUNDCOLOUR;
  1002. firstfont.parentNode.parentNode.style.borderTop="3px solid "+LOWAPBACKGROUNDCOLOUR;
  1003. firstfont.parentNode.parentNode.style.borderBottom="3px solid "+LOWAPBACKGROUNDCOLOUR;
  1004. firstfont.parentNode.parentNode.title="LOW AP";
  1005. //also color alll the pane titles gold so make sure waring is noticed.
  1006. var panetitles=document.getElementsByClassName("panetitle");
  1007. for (var i=0,temp=0;temp=panetitles[i] ;i++ ){
  1008. temp.style.color=LOWAPWARNINGCOLOUR;
  1009. temp.title='LOW AP';
  1010. }
  1011. //now also set the move buttons to dark orange.
  1012. /*
  1013. var movebuttons= document.evaluate("//input[@value='Move']", document, null,
  1014. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1015. var temp;
  1016. for (i=0;temp=movebuttons.snapshotItem(i) ;i++ ){
  1017. temp.style.color='red';
  1018. temp.style.fontWeight='bold';
  1019. }
  1020. */
  1021. }
  1022. else if(Number(secondfont.innerHTML.match(/\d+/))<50){
  1023. var hiddensmbutton= document.evaluate("//input[@value='Sorcerers Might']", document, null,
  1024. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
  1025. if(hiddensmbutton){
  1026. hiddensmbutton.nextElementSibling.style.color="red";
  1027. }
  1028. }
  1029. }
  1030. //HIGHLIGHT SM
  1031. var SMtext= document.evaluate("//td[@colspan='7']", document, null,
  1032. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);//find the form with name=pickup
  1033. var tempelement;
  1034. if (SMtext.snapshotLength>=1){//We have one or more candidates
  1035. for (var i=0;i<SMtext.snapshotLength;i++){
  1036. tempelement=SMtext.snapshotItem(i);
  1037. //if(tempelement.innerHTML.match(/Sorcerers Might/)){
  1038. // tempelement.style.color=SMWARNINGCOLOUR;
  1039. //}
  1040. if(tempelement.innerHTML.match(/Sorcerers Might/)){
  1041. tempelement.innerHTML=tempelement.innerHTML.replace(/(Sorcerers Might \([0-9]+ min\))/,'<span style="color:'+SMWARNINGCOLOUR+'">$1</span>');
  1042. }
  1043. if(tempelement.innerHTML.match(/Zerg Flag/)){
  1044. tempelement.innerHTML=tempelement.innerHTML.replace(/(Zerg Flag \([0-9]+ min\))/,'<span style="color:'+SMWARNINGCOLOUR+'">$1</span>');
  1045. }
  1046. }
  1047. }
  1048.  
  1049. //bugfix try fix door repair. game html is broken? and this script breaks it more.
  1050. //find this <form method="POST" action="modules.php?name=Game&op=door" name="doorrepair">
  1051. var doorrepair= document.evaluate("//form[@name='doorrepair']", document, null,
  1052. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);//this is the fubar possibly empty door repair form.
  1053.  
  1054. if (doorrepair.snapshotLength>=1){
  1055. doorrepair=doorrepair.snapshotItem(0);//only one item to be found
  1056. //<input type="submit" value="Repair Door (2 AP)">
  1057. //<input type="hidden" value="repair" name="action">
  1058. var repairinput=document.evaluate("//input[starts-with(@value,'Repair Door')]", document, null,
  1059. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1060. if (repairinput.snapshotLength>=1){
  1061. repairinput=repairinput.snapshotItem(0);
  1062. doorrepair.insertBefore(repairinput,doorrepair.firstElementChild);
  1063. }
  1064. repairinput=document.evaluate("//input[@value='repair' and @name='action']", document, null,
  1065. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1066. if (repairinput.snapshotLength>=1){
  1067. repairinput=repairinput.snapshotItem(0);
  1068. doorrepair.insertBefore(repairinput,doorrepair.firstElementChild);
  1069. }
  1070. //put it in a td. I don't know why it's invisible otherwise.
  1071. newtd=document.createElement('td');
  1072. doorrepair.parentNode.insertBefore(newtd,doorrepair.parentNode.lastElementChild);
  1073. newtd.insertBefore(doorrepair,newtd.firstElementChild)
  1074. }
  1075. //bugfix try fix lock picking
  1076. //<input type="submit" value="Pick Lock (1 AP)">
  1077. var LPButton= document.evaluate("//input[@value='Pick Lock (1 AP)']", document, null,
  1078. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);//this is the misplace lockppick button
  1079. if (LPButton.snapshotLength>=1){
  1080. //<form method="POST" action="modules.php?name=Game&amp;op=door" name="doorattack"> //stsrt of door attack form
  1081. //<form method="POST" action="modules.php?name=Game&amp;op=door" name="picklock"></form>
  1082. var LPForm= document.evaluate("//form[@name='picklock']", document, null,
  1083. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1084. if (LPForm.snapshotLength>=1){
  1085. LPForm.snapshotItem(0).appendChild(LPButton.snapshotItem(0))
  1086. }
  1087. //<input type="hidden" value="pick" name="action">
  1088. var LPhButton= document.evaluate("//input[@value='pick']", document, null,
  1089. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1090. if (LPhButton.snapshotLength>=1){
  1091. LPForm.snapshotItem(0).appendChild(LPhButton.snapshotItem(0))
  1092. }
  1093. //we not done.
  1094. //we must now take put form in td with open door or else it won't show for unknown reasons(might be css?
  1095. //<form method="POST" action="modules.php?name=Game&amp;op=door" name="dooropen">
  1096. var ODform= document.evaluate("//form[@name='dooropen']", document, null,
  1097. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1098. if (ODform.snapshotLength>=1){
  1099. ODform.snapshotItem(0).parentNode.insertBefore(LPForm.snapshotItem(0),ODform.snapshotItem(0))
  1100. }
  1101. }
  1102. //EOF
  1103. })();