Greasy Fork is available in English.

Trovo: Mana harvester

Get trovo mana

  1. // ==UserScript==
  2. // @name Trovo: Mana harvester
  3. // @name:ru Trovo: автосборщик маны
  4. // @description Get trovo mana
  5. // @description:ru Скрипт автоматического сбора маны
  6. // @namespace http://tampermonkey.net/
  7. // @version 0.0.8
  8. // @author traceer, xleeuwx
  9. // @match https://trovo.live/*
  10. // @grant none
  11. // @license MIT
  12. // @icon https://www.google.com/s2/favicons?domain=trovo.live
  13. // ==/UserScript==
  14.  
  15.  
  16. (function () {
  17. 'use strict';
  18. setTimeout(waitForInitialize, 30);
  19. }());
  20.  
  21. function waitForInitialize() {
  22. if (typeof window !== 'undefined') {
  23. initialize();
  24. } else {
  25. setTimeout(waitForInitialize, 30);
  26. }
  27. }
  28.  
  29. function initialize() {
  30. waitForFindButtonElement(0);
  31. console.log('Mana harvester is initialized');
  32. }
  33.  
  34. function waitForFindButtonElement(waitLonger) {
  35. if (waitLonger == 1) {
  36. var RandRangeNum = Math.floor(Math.random() * (270 - 120) + 120);
  37. } else {
  38. var RandRangeNum = Math.floor(Math.random() * (90 - 15) + 15);
  39. };
  40. setTimeout(findButtonElement, (RandRangeNum * 1000) );
  41. }
  42.  
  43. function findBoxElement() {
  44.  
  45. // find opened the Cast Spell box
  46. var foundBox = document.querySelectorAll("article.gift-box");
  47. var foundBtn = document.querySelectorAll("button.spell-btn");
  48. var foundProgress = document.querySelectorAll("div.progress-bg")
  49. var waitLonger = 0;
  50.  
  51. if(foundBox.length > 0) {
  52. console.log('Found the Cast Spell box, will close it');
  53. clickElement(foundBtn[0]);
  54. }
  55.  
  56. if(foundProgress.length > 0 && foundProgress[0].style.cssText == 'transform: scaleX(1);') {
  57. var waitLonger = 1;
  58. } else {
  59. var waitLonger = 0;
  60. }
  61.  
  62. // delete styles which hide the Cast Spell box
  63. const text = document.querySelectorAll('.giftbox-style');
  64. for (const el of text) {
  65. el.remove();
  66. }
  67. waitForFindButtonElement(waitLonger);
  68. }
  69.  
  70. function findButtonElement() {
  71.  
  72. // First find the chat element
  73. var foundButton = document.querySelectorAll("button.spell-btn");
  74. var foundGiftBox = document.querySelectorAll("article.gift-box");
  75.  
  76. if(foundButton.length > 0 && foundGiftBox.length != 1) {
  77. console.log('Found the damm button, now click it');
  78. if(typeof foundButton[0] !== 'undefined') {
  79. clickElement(foundButton[0]);
  80.  
  81. // add style for hide Cast Spell box
  82. var head = document.head || document.getElementsByTagName('head')[0];
  83. var style = document.createElement('style');
  84. var css = '.gift-box { display: none !important; }';
  85. style.type = 'text/css';
  86. style.classList.add("giftbox-style");
  87. style.appendChild(document.createTextNode(css));
  88. head.appendChild(style);
  89. }
  90.  
  91. setTimeout(findBoxElement, 1000 );
  92. } else {
  93. setTimeout(waitForFindButtonElement, 1000 );
  94. }
  95. }
  96.  
  97. function clickElement(buttonEl) {
  98. if(typeof buttonEl !== 'undefined' && buttonEl !== null) {
  99. try {
  100. buttonEl.click();
  101. console.log('i clicked it for you');
  102. } catch (e) {
  103. console.log('Cannot click the damm button, something whent wrong', e);
  104. }
  105. }
  106. }