chopcoin coords+timer

change title to show coordinates, and a 30 second timer after space has been pressed

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        chopcoin coords+timer
// @namespace   namespace
// @description change title to show coordinates, and a 30 second timer after space has been pressed
// @include     http://chopcoin.io/
// @version     1.1
// @grant       none
// ==/UserScript==

var timer = 0;
var xCoord = 0;
var yCoord = 0;


setTitle();
window.addEventListener("keydown", dealWithKeyboard, false);

function setTitle() {
  getCoords();
  document.title = xCoord + " : " + yCoord + " | " + timer;
  if (timer != 0) timer--;
  setTimeout(function(){ setTitle(); }, 1000);
}

function getCoords() {
  var rawNodes = chopcoin.game.nodes['all'];
	for(var i=0; i<rawNodes.length; i++) {
		if (rawNodes[i]._name) {
			xCoord = Math.round(rawNodes[i].x / 1000);
      yCoord = Math.round(rawNodes[i].y / 1000);
      //console.log(xCoord + " x " + yCoord);
		}
  }
}

function dealWithKeyboard(e) {
  if (e.keyCode == "32") timer = 30;
}