Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. // ==UserScript==
  2. // @name MouseMagelee 0.85
  3. // @namespace hentaiverse.org
  4. // @match *://*.hentaiverse.org/*
  5. // @run-at document-end
  6. // @grant none
  7. // ==/UserScript==
  8.  
  9. // ***THANKS***
  10. // sickentide (HV No Popup)
  11. // sigo8 (Reloader Shim)
  12.  
  13. // SETTINGS
  14. var hideLog = true;
  15. var defaultAction = [163,162,161]; //var defaultAction =0 for melee
  16. var minHP = 0.35;
  17. var minMP = 0.2;
  18. var minSP = 0.3;
  19. var rightClick = [311,313];
  20.  
  21.  
  22. var log = document.querySelector('#textlog > tbody');
  23. var paneCompletion = document.getElementById('pane_completion');
  24.  
  25. function canCast(id){
  26. var el = document.getElementById(id);
  27. return !!el && el.hasAttribute('onclick');
  28. }
  29. function setSpellAttack(id) {
  30. var caller = document.getElementById(id);
  31. window.battle.lock_action(caller, 1, 'magic', id);
  32. window.battle.set_hostile_skill(id);
  33. }
  34.  
  35. function castSupport(id) {
  36. var caller = document.getElementById(id);
  37. window.battle.lock_action(caller, 1, 'magic', id);
  38. window.battle.set_friendly_skill(id);
  39. window.battle.touch_and_go();
  40. }
  41.  
  42. function runRightClickSpell() {
  43. for (var i = 0; i < rightClick.length; i++) {
  44. if (canCast(rightClick[i])) {
  45. castSupport(rightClick[i]);
  46. return;
  47. }
  48. }
  49. }
  50.  
  51. function showGem() {
  52. var gem = document.getElementById('ikey_p');
  53. var gem_icon = document.getElementById('gem_icon');
  54. if (gem && !gem_icon) {
  55. var icon;
  56. switch (document.querySelector('#ikey_p > div > div').innerHTML.match(/([^\s]+) Gem/)[1]) {
  57. case 'Mystic':
  58. icon = 'channeling.png';
  59. break;
  60. case 'Health':
  61. icon = 'healthpot.png';
  62. break;
  63. case 'Mana':
  64. icon = 'manapot.png';
  65. break;
  66. case 'Spirit':
  67. icon = 'spiritpot.png';
  68. break;
  69. }
  70.  
  71. gem_icon = document.getElementById('pane_effects').appendChild(document.createElement('img'));
  72. gem_icon.src = '/y/e/' + icon;
  73. gem_icon.style.cssText = 'float: right;margin-right: 565px;';
  74.  
  75. function useGem(){
  76. window.battle.lock_action(gem, 1, 'items', 'ikey_p');
  77. window.battle.set_friendly_skill('999');
  78. window.battle.touch_and_go();
  79. gem.remove(); //probably useless
  80. gem_icon.remove();
  81. }
  82.  
  83. gem_icon.onclick = useGem;
  84. gem_icon.onmouseover = useGem;
  85. gem_icon.id = "gem_icon";
  86. } else if (!gem && gem_icon) {
  87. gem_icon.remove();
  88. }
  89. }
  90.  
  91. function reloadedEvent() {
  92. showGem();
  93. if(document.querySelector('#vbh img').width < 496*minHP) return;
  94. if(document.querySelector('#vbm img').width < 207*minMP) return;
  95. if(document.querySelector('#vbs img').width < 207*minSP) return;
  96.  
  97. if(defaultAction){
  98. for (var i = 0; i < defaultAction.length; i++) {
  99. if (canCast(defaultAction[i])) {
  100. setSpellAttack(defaultAction[i]);
  101. break;
  102. }
  103. }
  104. }
  105.  
  106. mpane = document.getElementById('pane_monster');
  107. var m = mpane.getElementsByClassName("btm1");
  108.  
  109. for (var j = 0; j < m.length; j++) {
  110. if (m[j].hasAttribute('onclick')) {
  111. m[j].setAttribute('onmouseover', m[j].getAttribute('onclick'));
  112. }
  113. }
  114. }
  115. function roundEndEvent() {
  116. var btcp = document.getElementById('btcp');
  117. if (btcp){
  118. if(document.querySelector('img[src$="finishbattle.png"]')){
  119. var endSheet = document.createElement('style');
  120. endSheet.innerHTML = '#btcp {display: block !important}';
  121. document.head.appendChild(endSheet);
  122. }
  123. else{
  124. btcp.click();
  125. }
  126. }
  127. }
  128.  
  129. function init() {
  130. if(!log) {
  131. return;
  132. }
  133. var obs = new MutationObserver(reloadedEvent);
  134. obs.observe(log, {childList: true});
  135.  
  136. var obs2 = new MutationObserver(roundEndEvent);
  137. obs2.observe(paneCompletion, {childList: true});
  138.  
  139. var sheet = document.createElement('style');
  140. sheet.innerHTML = '#btcp {display: none}';
  141. if(hideLog){
  142. sheet.innerHTML += '#pane_log {display: none}';
  143. }
  144. document.head.appendChild(sheet);
  145.  
  146. window.addEventListener('contextmenu', function (e) {
  147. e.preventDefault();
  148. runRightClickSpell();
  149. }, false);
  150.  
  151. reloadedEvent();
  152. }
  153. init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement