chopcoin coords+timer higher precision

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

  1. // ==UserScript==
  2. // @name chopcoin coords+timer higher precision
  3. // @namespace namespace
  4. // @description change title to show coordinates, and a 30 second timer after space has been pressed, updated by HPrivakos
  5. // @include http://chopcoin.io/
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var timer = 0;
  11. var xCoord = 0;
  12. var yCoord = 0;
  13.  
  14.  
  15. setTitle();
  16. window.addEventListener("keydown", dealWithKeyboard, false);
  17.  
  18. function setTitle() {
  19. getCoords();
  20. document.title = xCoord + " : " + yCoord + " | " + Math.round(timer / 10);
  21. if (timer != 0) timer--;
  22. setTimeout(function(){ setTitle(); }, 100);
  23. }
  24.  
  25. function getCoords() {
  26. var rawNodes = chopcoin.game.nodes['all'];
  27. for(var i=0; i<rawNodes.length; i++) {
  28. if (rawNodes[i]._name) {
  29. xCoord = Math.round(rawNodes[i].x / 100);
  30. yCoord = Math.round(rawNodes[i].y / 100);
  31. //console.log(xCoord + " x " + yCoord);
  32. }
  33. }
  34. }
  35.  
  36. function dealWithKeyboard(e) {
  37. if (e.keyCode == "32") timer = 300;
  38. }