NexusClashPetListonMouseover

Character Name title text shows a count of a characters pets that are present

  1. // ==UserScript==
  2. // @name NexusClashPetListonMouseover
  3. // @namespace http://userscripts.org/users/125692
  4. // @description Character Name title text shows a count of a characters pets that are present
  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. // @version 1.2
  10. // @grant none
  11. // ==/UserScript==
  12. //1.2 fix so doesn't have to have third party greasemeonkey script run first
  13. (function() {
  14. var characters= document.evaluate("//span[@class='char']", document, null,
  15. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  16. //alert(characters.snapshotLength);
  17. if (characters.snapshotLength>=1){//We have one or more candidates
  18. var ehighlightpet=function(e) {
  19. var charname=e.target.textContent;
  20. //either .trim or .slice(0, -1) to remove last character from string.
  21. var searchstring="Master: "+charname.trim();
  22. searchstring="//a[@title='"+searchstring+"']"
  23. var theirpets= document.evaluate(searchstring, document, null,
  24. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  25. var eachpet=0;
  26. //alert(theirpets.snapshotLength);
  27. if (theirpets.snapshotLength>=1){//We have one or more candidates
  28. e.target.title=(theirpets.snapshotLength + " pets present");
  29. var eachpet=0;
  30. for (var i=0;eachpet=theirpets.snapshotItem(i);i++){
  31. eachpet.style.color='blue';
  32. }
  33. }
  34. }
  35. var eunhighlightpet=function(e) {
  36. var charname=e.target.textContent;
  37. var searchstring="Master: "+charname.trim();
  38. searchstring="//a[@title='"+searchstring+"']"
  39. var theirpets= document.evaluate(searchstring, document, null,
  40. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  41. var eachpet=0;
  42. if (theirpets.snapshotLength>=1){//We have one or more candidates
  43. var eachpet=0;
  44. for (var i=0;eachpet=theirpets.snapshotItem(i);i++){
  45. //eachpet.style.fontStyle='normal';
  46. eachpet.style.color="";
  47. }
  48. }
  49. }
  50. var eachchar=0;
  51. for (var i=0;eachchar=characters.snapshotItem(i);i++){
  52. eachchar=eachchar.firstElementChild;
  53. eachchar.addEventListener("mouseover", ehighlightpet);
  54. eachchar.addEventListener("mouseout", eunhighlightpet);
  55. }
  56. }
  57. else {//we might still have people but we aren't using the character sort script
  58. //so find everyone bu liing for a with href starting with href="javascript:SelectItem('target_id',
  59. characters = document.evaluate(
  60. "//a[starts-with(@href,'javascript:SelectItem(')]",
  61. document,
  62. null,
  63. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  64. null );
  65. if (characters.snapshotLength>=1){//We have one or more candidates
  66. var ehighlightpet=function(e) {
  67. var charname=e.target.textContent; //either .trim or .slice(0, -1) to remove last character from string.
  68. var searchstring="Master: "+charname.trim();
  69. searchstring="//a[@title='"+searchstring+"']";
  70. var theirpets= document.evaluate(searchstring, document, null,
  71. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  72. var eachpet=0;
  73. if (theirpets.snapshotLength>=1){//We have one or more candidates
  74. e.target.title=(theirpets.snapshotLength + " pets present");
  75. var eachpet=0;
  76. for (var i=0;eachpet=theirpets.snapshotItem(i);i++){
  77. eachpet.style.color='blue';
  78. }
  79. }
  80. }
  81. var eunhighlightpet=function(e) {
  82. var charname=e.target.textContent;
  83. var searchstring="Master: "+charname.trim();
  84. searchstring="//a[@title='"+searchstring+"']";
  85. var theirpets= document.evaluate(searchstring, document, null,
  86. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  87. var eachpet=0;
  88. if (theirpets.snapshotLength>=1){//We have one or more candidates
  89. var eachpet=0;
  90. for (var i=0;eachpet=theirpets.snapshotItem(i);i++){
  91. //eachpet.style.fontStyle='normal';
  92. eachpet.style.color="";
  93. }
  94. }
  95. }
  96. var eachchar=0;
  97. for (var i=0;eachchar=characters.snapshotItem(i);i++){
  98. //eachchar=eachchar.firstElementChild;
  99. eachchar.addEventListener("mouseover", ehighlightpet);
  100. eachchar.addEventListener("mouseout", eunhighlightpet);
  101. }
  102. }
  103.  
  104. }
  105. //EOF
  106. })();