Eternity Tower Mining Details

Adds mining details to the UI for the Eternity Tower game

当前为 2017-11-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Eternity Tower Mining Details
  3. // @icon https://www.eternitytower.net/favicon.png
  4. // @namespace http://mean.cloud/
  5. // @version 1.02
  6. // @description Adds mining details to the UI for the Eternity Tower game
  7. // @match http*://*.eternitytower.net/*
  8. // @copyright 2017, MeanCloud
  9. // @run-at document-end
  10. // @auther Peter Souza
  11. // @modifier Deventur
  12. // ==/UserScript==
  13.  
  14. function addJQuery(callback)
  15. {
  16. var script = document.createElement("script");
  17. script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  18. script.addEventListener('load', function()
  19. {
  20. var script = document.createElement("script");
  21. script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
  22. document.body.appendChild(script);
  23. }, false);
  24. document.body.appendChild(script);
  25. }
  26.  
  27. function main()
  28. {
  29. jQ("head").append
  30. (
  31. "<style type=\"text/css\">\r\n" +
  32. ".ET_tooltip {\r\n" +
  33. " position: relative;\r\n" +
  34. " display: inline-block;\r\n" +
  35. "}\r\n" +
  36. "\r\n" +
  37. ".ET_tooltip .ET_tooltiptext {\r\n" +
  38. " visibility: hidden;\r\n" +
  39. " width: 120px;\r\n" +
  40. " background-color: #555;\r\n" +
  41. " color: #fff;\r\n" +
  42. " text-align: center;\r\n" +
  43. " border-radius: 6px;\r\n" +
  44. " padding: 5px 0;\r\n" +
  45. " position: absolute;\r\n" +
  46. " z-index: 1;\r\n" +
  47. " bottom: 125%;\r\n" +
  48. " left: 50%;\r\n" +
  49. " margin-left: -60px;\r\n" +
  50. " opacity: 0;\r\n" +
  51. " transition: opacity 1s;\r\n" +
  52. "}\r\n" +
  53. "\r\n" +
  54. ".ET_tooltip .ET_tooltiptext::after {\r\n" +
  55. " content: \"\";\r\n" +
  56. " position: absolute;\r\n" +
  57. " top: 100%;\r\n" +
  58. " left: 50%;\r\n" +
  59. " margin-left: -5px;\r\n" +
  60. " border-width: 5px;\r\n" +
  61. " border-style: solid;\r\n" +
  62. " border-color: #555 transparent transparent transparent;\r\n" +
  63. "}\r\n" +
  64. "\r\n" +
  65. ".ET_tooltip:hover .ET_tooltiptext {\r\n" +
  66. " visibility: visible;\r\n" +
  67. " opacity: 1;\r\n" +
  68. "</style>\r\n" +
  69. "}\r\n"
  70. );
  71.  
  72. // Set background tasks
  73. setTimeout(document.ET_fnRender, 1000);
  74. }
  75.  
  76. document.ET_fnRender = function()
  77. {
  78. jQ(".ET_extradetails").remove();
  79.  
  80. jQ("div.mine-space-container").css("backgroundColor", "");
  81.  
  82. jQ("div.mine-space-container > img").each(function()
  83. {
  84. function trim(str, charlist)
  85. {
  86. charlist = !charlist ? " \s\r\n\t\xA0\x0B\0" :
  87. charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, "\$1");
  88.  
  89. var re = new RegExp("^[" + charlist + "]+|[" + charlist + "]+$", "g");
  90.  
  91. return str.replace(re, '');
  92. }
  93. var oParent = jQ(this).parent();
  94. var sHTML = oParent.html();
  95.  
  96. var iCurDmgMining = 37;
  97.  
  98. var sType = document.ChopperBlank(sHTML, "/icons/", ".");
  99. var sSpanVal = document.ChopperBlank(sHTML, '<span style="font-size: 12px; white-space: nowrap">', '</span>');
  100. var sHealth = trim(sSpanVal.split(' / ')[0]);
  101. sHealth = sHealth.indexOf('k')!=-1 ? parseInt(parseFloat(sHealth.substring(0, sHealth.length - 1))*1000) : parseInt(sHealth);
  102. var sMaxHealth = trim(sSpanVal.split(' / ')[1]);
  103. sMaxHealth = sMaxHealth.indexOf('k')!=-1 ? parseInt(parseFloat(sMaxHealth.substring(0, sMaxHealth.length - 1))*1000) : parseInt(sMaxHealth);
  104. //console.log(sHealth + ' / ' + sMaxHealth);
  105.  
  106. if (sType.length > 0)
  107. {
  108. if (sType.indexOf("Cluster") !== -1)
  109. sType = document.ChopperBlank(sType, "", "Cluster");
  110.  
  111. sType = sType.toLowerCase();
  112.  
  113. if (sType == "gem") sType = "GEM";
  114. else if (sType == "stone") sType = "STONE";
  115. else if (sType == "copper") sType = "COPPER";
  116. else if (sType == "coal") sType = "COAL";
  117. else if (sType == "tin") sType = "TIN";
  118. else if (sType == "bronze") sType = "BRONZE";
  119. else if (sType == "iron") sType = "IRON";
  120. else if (sType == "silver") sType = "SILVER";
  121. else if (sType == "gold") sType = "GOLD";
  122. else if (sType == "carbon") sType = "CARBON";
  123. else if (sType == "steel") sType = "STEEL";
  124. else if (sType == "platinum") sType = "PLATINUM";
  125. else if (sType == "titanium") sType = "TITANIUM";
  126. else if (sType == "tungsten") sType = "TUNGSTEN";
  127. else if (sType == "obsidian") sType = "OBSIDIAN";
  128. else if (sType == "cobalt") sType = "COBALT";
  129.  
  130. else if (sType == "silveressence") sType = "ESSENCE (silver)";
  131. else if (sType == "goldessence") sType = "ESSENCE (gold)";
  132. else if (sType == "carbonessence") sType = "ESSENCE (carbon)";
  133. else if (sType == "steelessence") sType = "ESSENCE (steel)";
  134. else if (sType == "platinumessence") sType = "ESSENCE (platinum)";
  135. else if (sType == "titaniumessence") sType = "ESSENCE (titanium)";
  136. else if (sType == "tungstenessence") sType = "ESSENCE (tungsten)";
  137. else if (sType == "obsidianessence") sType = "ESSENCE (obsidian)";
  138. else if (sType == "cobaltessence") sType = "ESSENCE (cobalt)";
  139.  
  140. else if (sType == "jade") sType = "GEM (jade)";
  141. else if (sType == "lapis") sType = "GEM (lapis)";
  142. else if (sType == "sapphire") sType = "GEM (sapphire)";
  143. else if (sType == "ruby") sType = "GEM (ruby)";
  144. else if (sType == "emerald") sType = "GEM (emerald)";
  145.  
  146. else sType = sType.toUpperCase();
  147.  
  148. oParent.append("<div class=\"ET_extradetails\" style=\"font-size: 10px; margin-top: -14px; margin-bottom: 4px;\"><br />" + sType + "</div>");
  149.  
  150. if (sType == "GEM") oParent.css("backgroundColor", "#e7cff7");
  151. else if (sHealth < iCurDmgMining*3) oParent.css("backgroundColor", "#05a3a3");
  152. else if (sHealth < (iCurDmgMining*10)+40 && sHealth > (iCurDmgMining*10)-40 ) oParent.css("backgroundColor", "#29ab87");
  153. //else if (sHealth < 30) oParent.css("backgroundColor", "#d3d1d6");
  154. //else if (sType == "STONE") oParent.css("backgroundColor", "#d3d1d6");
  155. //else if (sType == "COAL") oParent.css("backgroundColor", "#b9b4b2");
  156. else if (sType.indexOf("ESSENSE") !== -1) oParent.css("backgroundColor", "#f9e9c7");
  157. else if (sType.indexOf("GEM (") !== -1) oParent.css("backgroundColor", "#ccf9c7");
  158. }
  159. });
  160.  
  161. setTimeout(document.ET_fnRender, 1000);
  162. };
  163.  
  164. document.ChopperBlank = function (sText, sSearch, sEnd)
  165. {
  166. var sIntermediate = "";
  167.  
  168. if (sSearch === "")
  169. sIntermediate = sText.substring(0, sText.length);
  170. else
  171. {
  172. var iIndexStart = sText.indexOf(sSearch);
  173. if (iIndexStart === -1)
  174. return "";
  175.  
  176. sIntermediate = sText.substring(iIndexStart + sSearch.length);
  177. }
  178.  
  179. if (sEnd === "")
  180. return sIntermediate;
  181.  
  182. var iIndexEnd = sIntermediate.indexOf(sEnd);
  183.  
  184. return (iIndexEnd === -1) ? sIntermediate : sIntermediate.substring(0, iIndexEnd);
  185. };
  186.  
  187. addJQuery(main);