RW hunter

support RW

  1. // ==UserScript==
  2. // @name RW hunter
  3. // @namespace eRRW
  4. // @author iMan (Persian Myth)
  5. // @description support RW
  6. // @version 1.1
  7. // @include https://www.erepublik.com/*
  8. // ==/UserScript==
  9. var ResistanceForceInsert = function($, window, undefined) {
  10. function supportRW() {
  11. setTimeout(function () {
  12. $('#fundRW_btn2').trigger('click');
  13. console.log('[RW hunter] Support button clicked');
  14. // If the button has a class disabled it should mean the RW is supported
  15. if (!document.getElementById('fundRW_btn').classList.contains('disabled')) {
  16. supportRW();
  17. } else {
  18. console.log('[RW hunter] RW supported successfully');
  19. };
  20. }, 1000) // Delay(ms) in which script tries to support again
  21. }
  22. function controlIt(control){GM_setValue("control", control);}
  23. function autoRefresh(interval) {setTimeout('location.reload(true);',interval);};
  24. $(document).ready(function () {
  25. if (parent.document.location.toString()==='https://www.erepublik.com/en') {
  26. if ($('#battle_listing > ul.resistance_war > li > a#fundRW_btn').length==1) {
  27. supportRW();
  28. } else {
  29. var vNmax = 1; var vNmin = 1;
  30. var vNum = Math.round(Math.random() * (vNmax - vNmin) + vNmin);
  31. autoRefresh(vNum*1000);
  32. };
  33. };
  34. });
  35. };
  36. // Script Insert
  37. var script = document.createElement('script');
  38. script.textContent = '(' + ResistanceForceInsert + ')(jQuery, window);';
  39. document.body.appendChild(script);