这就是我到目前为止...我刚开始使用javascript for tampermonkey并且我试图让脚本按下w时间为X时间,然后是d,s和a相同的时间,但按键都被按下了同时......我也想弄清楚如何制作这个功能循环 . 请帮助,并了解我只是一个弱小的初学者,没有任何经验或线索发生的事情 .

(function() {
'use strict';
var flag = 0;
setInterval(function(){

    if(document.getElementById( "a" ).style.display == null || document.getElementById( "a" ).style.display !== "none" ){
    if(flag == 1)flag = 0;
    input.keyUp(65);
    input.keyDown(13);//「Enter」
    setTimeout(function(){ input.keyUp(13);}, 300);
    }
    else{
if(flag == 0){
flag = 1;
input.keyDown(75);//「K」
setTimeout(function(){ input.keyUp(75);}, 2000);
input.set_convar('game_stats_build','8888888');//speed MAX
}
setTimeout(function(){
input.keyDown(87);//
    setTimeout(function(){ input.keyUp(87);}, 12000);
input.keyDown(68);//
    setTimeout(function(){ input.keyUp(68);}, 12000);
input.keyDown(83);
    setTimeout(function(){ input.keyUp(83);}, 12000);
input.keyDown(65);
    setTimeout(function(){ input.keyUp(65);}, 12000);
}, 2000);
    }

    }, 2000);
})();