Autostrife

Automatically strifes on the Overseer project.

目前為 2014-10-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Autostrife
  3. // @namespace http://gigapause.com/
  4. // @version 0.9.1
  5. // @description Automatically strifes on the Overseer project.
  6. // @author capableResistor
  7. // @grant none
  8. // @match http://*.theoverseerproject.com/*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. function strife(){
  13. createInput();
  14. if($('#aspect').length){
  15. var healthcontainer = $('#banner > div.intercross > span > div.pined');
  16. var encountercontainer = $('#banner > div.intercross > div.lefy > span');
  17. var health = healthcontainer.html();
  18. var encounters = encountercontainer.html();
  19. health = health.replace( /^\D+/g, '');
  20. health = health.replace('%','');
  21. encounters = encounters.replace( /^\D+/g, '');
  22. document.title = "H: " + Number(health) + "%" + " E: " + Number(encounters) + ". Overseer";
  23. if (getCookie('autostrife') === "") {
  24. console.log("====> Autostrife cookie not set. Not autostrifing.");
  25. } else if (getCookie('autostrife') == "doStrife" || getCookie('autostrife') == "doGrind") {
  26. if(Number(health) < 20 && getCookie('autostrife') == "doStrife") {
  27. //abscond();
  28. console.log("====> Too dangerous to autostrife (Health below 20%). Manual intervention required.");
  29. } else {
  30. attack();
  31. }
  32. if (Number(health) < 5 && getCookie('autostrife') == "doGrind") {
  33. console.log("====> Looks like you're in trouble. Get healed above 5% before you attempt grinding and sure you're taking on enemies you're very sure you can defeat easily.");
  34. } else {
  35. attack();
  36. }
  37. } else {
  38. console.log("====> Error: Cookie setting mismatch. Resetting cookie.");
  39. unsetCookie('autostrife');
  40. }
  41. } else if ($('#canner a').length > 0 && $.trim($('#canner a').text()) == "Strife again" && getCookie('autostrife') == "doStrife") {
  42. console.log("====> Strife concluded.");
  43. unsetCookie('autostrife');
  44. } else if ($('#canner a').length > 0 && $.trim($('#canner a').text()) == "Strife again" && getCookie('autostrife') == "doGrind") {
  45. console.log("====> Strife concluded, but grind mode is on.");
  46. window.location.href = 'strife.php';
  47. } else if ($('input[type="submit"][value="Fight these enemies again!"]').length && getCookie('autostrife') == "doGrind") {
  48. console.log("====> On strife init page, and autoGrind is on.");
  49. var encountercontainer2 = $('#banner > div.intercross > div.lefy > span');
  50. var encounters2 = encountercontainer2.html();
  51. encounters2 = encounters2.replace( /^\D+/g, '');
  52. if (Number(encounters2) === 0) {
  53. console.log("====> However, there are no encounters left. Grinding is over.");
  54. unsetCookie('autostrife');
  55. } else {
  56. console.log("====> We have " + Number(encounters2) + " enounter(s) to work with.");
  57. initiate();
  58. }
  59. } else {
  60. console.log("====> Nothing to do right now.");
  61. var encountercontainer3 = $('#banner > div.intercross > div.lefy > span');
  62. var encounters3 = encountercontainer3.html();
  63. encounters3 = encounters3.replace( /^\D+/g, '');
  64. if (Number(encounters3) === 0 && getCookie('autostrife') == "doGrind" ) {
  65. console.log("====> There are no encounters left. Grinding is over.");
  66. unsetCookie('autostrife');
  67. }
  68. }
  69. }
  70.  
  71. function setCookie(cname, cvalue, exdays){
  72. var d = new Date();
  73. d.setTime(d.getTime() + (exdays*24*60*60*1000));
  74. var expires = "expires="+d.toUTCString();
  75. document.cookie = cname + "=" + cvalue + "; " + expires;
  76. }
  77.  
  78. function unsetCookie(cname){
  79. document.cookie = cname + "=''; expires=-1";
  80. }
  81.  
  82. function getCookie(cname){
  83. var name = cname + "=";
  84. var ca = document.cookie.split(';');
  85. for(var i=0; i<ca.length; i++) {
  86. var c = ca[i];
  87. while (c.charAt(0)==' ') c = c.substring(1);
  88. if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
  89. }
  90. return "";
  91. }
  92.  
  93. function createInput(){
  94. var atbutton = $('input[type="submit"][value="Abscond"]');
  95. var userinfo = $('#banner > div.intercross > span > div.lined > a');
  96. if(atbutton.length > 0){
  97. atbutton.after($('</br><input type="button" id="autostrife" name="astrife" value="autoStrife();"><input type="button" id="autogrind" name="agrind" value="autoGrind();">'));
  98. document.getElementById('autostrife').addEventListener("click", autoStrife, false);
  99. document.getElementById('autogrind').addEventListener("click", autoGrind, false);
  100. }
  101. if(userinfo.length > 0){
  102. userinfo.after($('<span class="rhyme slam astop" id="stop">STOPAUTO();</span>'));
  103. userinfo.after($('<style>#stop {\ncolor: #000;\nmargin-left: auto;\nmargin-right: auto;\nmargin-top: 5px;\n}\n#stop:active {\nbackground-color: #444;\ncolor: #FFF;\n}\n#stop:hover {\noutline: thin red solid\n}</style>'));
  104. document.getElementById('stop').addEventListener("click", stop, false);
  105. }
  106. }
  107.  
  108. function attack(){
  109. var atbutton = $('input[type="submit"][value="Attack"]');
  110. atbutton.trigger("click");
  111. }
  112.  
  113. function abscond(){
  114. var abbutton = $('input[type="submit"][value="Abscond"]');
  115. abbutton.trigger("click");
  116. }
  117.  
  118. function initiate(){
  119. var lastbutton = $('input[type="submit"][value="Fight these enemies again!"]');
  120. lastbutton.trigger("click");
  121. }
  122.  
  123. function autoStrife(){
  124. setCookie('autostrife', 'doStrife', '1');
  125. window.location.href = 'strife.php';
  126. }
  127.  
  128. function autoGrind(){
  129. setCookie('autostrife', 'doGrind', '7');
  130. window.location.href = 'strife.php';
  131. }
  132.  
  133. function stop(){
  134. unsetCookie('autostrife');
  135. console.log("====> Unsetting autostrife and autogrind.");
  136. }
  137.  
  138. setTimeout( strife(), 3000 );

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址