N1bot inputs

Convenience script for using the N1 bot.

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

  1. // ==UserScript==
  2. // @name N1bot inputs
  3. // @namespace yichizhng@gmail.com
  4. // @include http://www.animecubed.com/billy/bvs/numberone.html
  5. // @version 1.1
  6. // @grant none
  7. // @description Convenience script for using the N1 bot.
  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 copyText = document.createElement("p");
  28. copyText.textContent = txts;
  29. document.maction.parentElement.insertBefore(copyText, document.maction);
  30. // txts.onclick = function() {
  31. window.getSelection().selectAllChildren(copyText);
  32. // }
  33. var n1input = document.createElement("input");
  34. document.maction.parentElement.insertBefore(n1input, document.maction);
  35. var action_map = {
  36. "Reload": "1^0",
  37. "Block": "2^0",
  38. "Fire 1": "3^1",
  39. "Fire 2": "3^2",
  40. "Fire 3": "3^3",
  41. "Fire 4": "3^4",
  42. "Fire 5": "3^5",
  43. "Fire 6": "3^6"
  44. };
  45. var selectors = document.maction.querySelectorAll("select");
  46. n1input.addEventListener("paste", function(e) {
  47. e.preventDefault();
  48. var myRegExp = /\: +(.+)/g; // the only thing this doesn't parse is "Reload (Game is already over)", which is a reload
  49. var text = e.clipboardData.getData('text/plain');
  50. //console.log(text);
  51. var i = 0;
  52. while (match = myRegExp.exec(text)) {
  53. if (i >= selectors.length) break;
  54. selectors[i++].value = action_map[match[1]] || "1^0";
  55. // console.log(match[1]);
  56. }
  57. //console.log( e.clipboardData.getData('text/plain'));
  58. }, false);
  59. }
  60.  
  61. N1Bot();