N1bot inputs

Convenience script for using the N1 bot.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        N1bot inputs
// @description Convenience script for using the N1 bot.
// @namespace   [email protected]
// @include     http://www.animecubed.com/billy/bvs/numberone.html
// @version     1.2
// @grant       none
// ==/UserScript==

function N1Bot() {
    var matches = document.maction.querySelectorAll("td");
    txts = "";
    for (var i = 0; i < matches.length; i++) {
        var selector = matches[i].querySelector("select");
        if (!selector) continue;
        // console.log(selector ? selector.name : "");
        //var powahs = matches[i].querySelectorAll("img");
        var txt = selector.name + matches[i].textContent;
        txt = txt.slice(0, txt.search("Your Action:"));
        txt = txt.slice(txt.search("HP"));
        txt = txt.replace(/\n/g, " ");
        //console.log(txt);
        txts += txt;
    }
    // console.log(txts);
    
   // document.body.innerHTML = document.body.innerHTML.replace(/<b>Your In-Progress Matches<\/b>/g, '<p>' + txts + "</p>");
    var copyText = document.createElement("p");
    copyText.textContent = txts;
    document.maction.parentElement.insertBefore(copyText, document.maction);
   // txts.onclick = function() {
        window.getSelection().selectAllChildren(copyText);
   // }
    
    var n1input = document.createElement("input");
    document.maction.parentElement.insertBefore(n1input, document.maction);
  var action_map = {
    "Reload": "1^0",
    "Block": "2^0",
    "Fire 1": "3^1",
    "Fire 2": "3^2",
    "Fire 3": "3^3",
    "Fire 4": "3^4",
    "Fire 5": "3^5",
    "Fire 6": "3^6"
  };
  var selectors = document.maction.querySelectorAll("select");
  
    n1input.addEventListener("paste", function(e) {
      e.preventDefault();
      var myRegExp = /\: +(?:Autoload! )?(.+)/g; // the only thing this doesn't parse is "Reload (Game is already over)", which is a reload
      var text = e.clipboardData.getData('text/plain');
      //console.log(text);
      var i = 0;
      while (match = myRegExp.exec(text)) {
        if (i >= selectors.length) break;
        
        selectors[i++].value = action_map[match[1]] || "1^0";
        // console.log(match[1]);
      } 
      //console.log( e.clipboardData.getData('text/plain'));
    }, false);
}

N1Bot();