chopcoin timer/nodecount/coordinates

change title to show a 30 second timer on split, number of nodes, and rough coordinates

  1. // ==UserScript==
  2. // @name chopcoin timer/nodecount/coordinates
  3. // @namespace namespace
  4. // @description change title to show a 30 second timer on split, number of nodes, and rough coordinates
  5. // @include http://chopcoin.io/
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var timer = 0;
  11. var timerFloat = 0;
  12. var xCoord = 0;
  13. var yCoord = 0;
  14. var nodeCount = 0;
  15. var frequency = 2; // how many times per second to update title
  16. var id = 0;
  17. var ign = "nothing";
  18. var precision = 1000; // number to divide the board by, since its 12,000 x 12,000
  19.  
  20. setTitle();
  21. window.addEventListener("keydown", dealWithKeyboard, false);
  22.  
  23. function setTitle() {
  24. getCoords();
  25. if (timerFloat != 0) {
  26. timerFloat -= 1/frequency;
  27. timer = Math.round(timerFloat);
  28. }
  29. document.title = timer + " | " + nodeCount + " | " + xCoord + " : " + yCoord + ' ' + ign;
  30. setTimeout(function(){ setTitle(); }, 1000/frequency);
  31. }
  32.  
  33. function getCoords() {
  34. id = chopcoin.game.nodes.player_id['length'] - 1; // hackish way to identify my blob
  35. if (!chopcoin.game.nodes.player_id[id]) id = -1; // chopcoin doesnt clear out on spectate
  36. xCoord = 0;
  37. yCoord = 0;
  38. nodeCount = 0;
  39. var rawNodes = chopcoin.game.nodes['all'];
  40. for(var i=0; i<rawNodes.length; i++) {
  41. if (id == -1 && rawNodes[i]._name) id = rawNodes[i].id; // while in spectate mode, take the id of the first node that has a name
  42. if (rawNodes[i].id == id) ign = rawNodes[i]._name; // should be in a seperate for loop to get name?
  43. if (rawNodes[i]._name == ign) {
  44. nodeCount++;
  45. //xCoord += Math.round(rawNodes[i].x / 1000);
  46. //yCoord += Math.round(rawNodes[i].y / 1000);
  47. xCoord += rawNodes[i].x;
  48. yCoord += rawNodes[i].y;
  49. //console.log(xCoord + " : " + yCoord + " nodecount=" + nodeCount + ", name=" + ign);
  50. }
  51. }
  52. xCoord = Math.round(xCoord / nodeCount/ precision);
  53. yCoord = Math.round(yCoord / nodeCount/ precision);
  54. if(isNaN(xCoord)) xCoord = 0; // why are we getting NaNs here sometimes
  55. if(isNaN(yCoord)) yCoord = 0;
  56. }
  57.  
  58. function dealWithKeyboard(e) {
  59. if (e.keyCode == "32") timerFloat = 30;
  60. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址