BvS Number One Bot

Play BvS minigame Number One

目前为 2018-03-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name BvS Number One Bot
  3. // @namespace SkySkimmer
  4. // @description Play BvS minigame Number One
  5. // @version 5.0.4
  6. // @include http*://*animecubed.com/billy/bvs/numberone.html
  7. // @include http*://*animecubedgaming.com/billy/bvs/numberone.html
  8. // @require https://greasyfork.org/scripts/39671-lib-number-one/code/lib_number_one.js
  9. // @resource states http://thedragonrider.free.fr/states.json
  10. // @licence https://github.com/SkySkimmer/number_one_runner/blob/master/src/LICENSE
  11. // @grant GM_getResourceText
  12. // ==/UserScript==
  13.  
  14.  
  15. // go from the index in the list of selectors for a game to the property name in a strategy
  16. function semantic_index(i) {
  17. if (i == 0)
  18. return "p1Move";
  19.  
  20. // first doubletime action is reload which is -1, minus offset
  21. // from initial action we need 1 => -1
  22. i -= 2;
  23.  
  24. return i.toString();
  25. }
  26.  
  27. function botGame(states, elmt) {
  28. var selects = elmt.querySelectorAll("select");
  29. if (!selects || selects.length == 0) {
  30. // nothing to do
  31. return ;
  32. }
  33.  
  34. var state = parseGame(elmt);
  35. var strat = get_doubletime_strat(states, state);
  36. for(var i=0; i < selects.length; i++) {
  37. var index = semantic_index(i);
  38. selects[i].value = action_map[strat[index]];
  39. }
  40. }
  41.  
  42. function N1Bot() {
  43. var states = GM_getResourceText("states");
  44.  
  45. var matches = document.forms["maction"].querySelectorAll("td");
  46. for (var i = 0; i < matches.length; i++) {
  47. botGame(states, matches[i]);
  48. }
  49. }
  50.  
  51. if(/Your In-Progress Matches/.test(document.body.innerHTML))
  52. N1Bot();