eRev Improver

Añade mejoras a eRevollution.com

  1. // ==UserScript==
  2. // @name eRev Improver
  3. // @namespace https://greasyfork.org/es/scripts/21827-erev-improver
  4. // @version 0.4
  5. // @description Añade mejoras a eRevollution.com
  6. // @author DonNadie
  7. // @match https://www.erevollution.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function()
  12. {
  13. 'use strict';
  14.  
  15. var eImprover = function()
  16. {
  17. var oldHealth = {},
  18. config = {
  19. hideBattleResults: true
  20. };
  21.  
  22. var init = function()
  23. {
  24. if (localStorage.getItem("erev-improver")) {
  25. config = JSON.parse(localStorage.getItem("erev-improver"));
  26. }
  27.  
  28. // detect changes on player health and max regen
  29. $('#energyBarT, #energyButtonT').on("DOMSubtreeModified", function() {
  30. showMaxRegenBar();
  31. });
  32.  
  33. // click on local feeds/news
  34. $('a[data-target="#tab-feeds4"]').click();
  35. $('a[href="#tab-national"]').click();
  36.  
  37. showMaxRegenBar();
  38.  
  39. if (config.hideBattleResults) {
  40. hideBattleResults();
  41. }
  42.  
  43. // remove energy time loader image
  44. $('#energyTime img').remove();
  45.  
  46. // fix comment's newlines
  47. $('.conversation-item.item-left.clearfix .text').each(function() {
  48. $(this).html($(this).html().replace(/\n/g, "<br>"));
  49. });
  50. };
  51.  
  52. var hideBattleResults = function ()
  53. {
  54. $('body').append(parseTemplate(function() {
  55. /*
  56. <style>
  57. #battleBlack, #battleLog {
  58. display: none !important;
  59. </style>
  60. }*/
  61. }));
  62. };
  63.  
  64. var showMaxRegenBar = function()
  65. {
  66. var tmp = $('#energyBarT').text().split(' / '),
  67. health = {
  68. current: parseInt(tmp[0]),
  69. max: parseInt(tmp[1])
  70. },
  71. $maxHealth = $('#max-health');
  72.  
  73. health.maxRegex = parseInt($('#energyButtonT').text()) + health.current;
  74.  
  75. if (health.current < 0 || health.max < 0 || isNaN(health.current) || isNaN(health.current) || isNaN(health.maxRegex) || oldHealth == health) {
  76. return;
  77. }
  78. oldHealth = health;
  79.  
  80. // first load, setup everything
  81. if ($maxHealth.length === 0)
  82. {
  83. $('body').append(parseTemplate(function() {
  84. /*
  85. <style>
  86. .vs100.progress {
  87. background: transparent !important;
  88. }
  89.  
  90. #max-health {
  91. width: 100%;
  92. height: 3vh;
  93. position: absolute;
  94. z-index: -1;
  95. border: 0;
  96. }
  97.  
  98. #max-health::-webkit-progress-bar {
  99. background-color: #eee;
  100. }
  101. #max-health::-webkit-progress-value {
  102. background: #a7d8a7;
  103. }
  104. </style>
  105. */
  106. }));
  107.  
  108. $('#energyBarP').before('<progress id="max-health" value="' + health.maxRegex + '" max="' + health.max + '"></progress>');
  109. } else {
  110. $maxHealth.val(health.maxRegex);
  111. $maxHealth.attr("max", health.max);
  112. }
  113. };
  114.  
  115. var parseTemplate = function(func) {
  116. return func.toString().replace(/^[^\/]+\/\*!?/, '').replace(/\*\/[^\/]+$/, '');
  117. };
  118.  
  119. $(function() {
  120. setTimeout(init, 1000);
  121. });
  122. }();
  123. })();