N1bot inputs

Convenience script for using the N1 bot.

当前为 2016-03-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name N1bot inputs
  3. // @namespace yichizhng@gmail.com
  4. // @description Convenience script for using the N1 bot.
  5. // @include http://www.animecubed.com/billy/bvs/numberone.html
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. function N1Bot() {
  11. var matches = document.maction.querySelectorAll("td");
  12. txts = "";
  13. for (var i = 0; i < matches.length; i++) {
  14. var selector = matches[i].querySelector("select");
  15. if (!selector) continue;
  16. // console.log(selector ? selector.name : "");
  17. //var powahs = matches[i].querySelectorAll("img");
  18. var txt = selector.name + matches[i].textContent;
  19. txt = txt.slice(0, txt.search("Your Action:"));
  20. txt = txt.slice(txt.search("HP"));
  21. txt = txt.replace(/\n/g, " ");
  22. //console.log(txt);
  23. txts += txt;
  24. }
  25. // console.log(txts);
  26. document.body.innerHTML = document.body.innerHTML.replace(/<b>Your In-Progress Matches<\/b>/g, '<p>' + txts + "</p>");
  27. var n1input = document.createElement("input");
  28. document.maction.parentElement.insertBefore(n1input, document.maction);
  29. var action_map = {
  30. "Reload": "1^0",
  31. "Block": "2^0",
  32. "Fire 1": "3^1",
  33. "Fire 2": "3^2",
  34. "Fire 3": "3^3",
  35. "Fire 4": "3^4",
  36. "Fire 5": "3^5",
  37. "Fire 6": "3^6"
  38. };
  39. var selectors = document.maction.querySelectorAll("select");
  40. n1input.addEventListener("paste", function(e) {
  41. e.preventDefault();
  42. var myRegExp = /\: +(.+)/g; // the only thing this doesn't parse is "Reload (Game is already over)", which is a reload
  43. var text = e.clipboardData.getData('text/plain');
  44. //console.log(text);
  45. var i = 0;
  46. while (match = myRegExp.exec(text)) {
  47. if (i >= selectors.length) break;
  48. selectors[i++].value = action_map[match[1]] || "1^0";
  49. // console.log(match[1]);
  50. }
  51. //console.log( e.clipboardData.getData('text/plain'));
  52. }, false);
  53. }
  54.  
  55. N1Bot();