respawn script for tricksplit.io

instantly respawn with a press of a button

As of 2020-07-20. See the latest version.

// ==UserScript==
// @name         respawn script for tricksplit.io
// @namespace    http://tampermonkey.net/
// @version      1,3
// @description  instantly respawn with a press of a button
// @author       sos
// @match        https://tricksplit.io/
// @grant        none
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
let menu = document.getElementsByClassName('menu');
let endPanel = document.getElementsByClassName('end');
document.getElementById('freeCoins').onclick = function() {
 console.log('auto coins collection started');
 setInterval(collectCoins, 7201000);
} 


function collectCoins() {

   window.game.api.utils.claimFreeCoins();

}
function keydown(event) {
    if (event.keyCode == 68) { // D
        spawn();
    }
}
function keyup(event) {
    if (event.keyCode == 68) { // D
        return;
    }
}


function spawn() {
   if (menu[0].style.display === "none") {
   window.game.socket.connect("ws://${this.selectedServer}");
   endPanel[0].style.display = "none";
   document.getElementById('overlays').style.display = "none";
   setTimeout(spawn2, 1000);
   }
}
function spawn2() {
   window.game.spawn();
}