Bloble.io NoobScript V3 InstaFind Fragment

A fragment of code from NoobScript V3 - The instant player find feature. Click on a name on the leaderboard or click on a name in the chat to instantly find them. Use the < and > keys to navigate as well.

目前为 2018-01-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Bloble.io NoobScript V3 InstaFind Fragment
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description A fragment of code from NoobScript V3 - The instant player find feature. Click on a name on the leaderboard or click on a name in the chat to instantly find them. Use the < and > keys to navigate as well.
  6. // @author NoobishHacker
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10. var gotoUsers = [];
  11. var gotoIndex = 0;
  12.  
  13. leaderboardList.style.pointerEvents = 'auto';
  14. chatListWrapper.style.pointerEvents = 'auto';
  15.  
  16. window.goto = function(username) {
  17. gotoUsers = users.filter((user) => {
  18. return user.name === username
  19. });
  20. gotoIndex = 0;
  21. if (gotoUsers[0]) {
  22. camX = gotoUsers[0].x - player.x;
  23. camY = gotoUsers[0].y - player.y;
  24. }
  25. addChat(gotoUsers.length + ' users found with the name ' + username, 'Client');
  26. return gotoUsers.length;
  27. }
  28. window.goto2 = function(id, go) {
  29. gotoUsers = users.filter((user) => {
  30. return user.sid === id;
  31. });
  32. gotoIndex = 0;
  33. if (!go && gotoUsers[0]) {
  34. camX = gotoUsers[0].x - player.x;
  35. camY = gotoUsers[0].y - player.y;
  36. }
  37. return gotoUsers.length;
  38. }
  39.  
  40. window.gotoLeft = function() {
  41. if (!gotoUsers.length) return;
  42.  
  43. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  44. if (gotoIndex <= 0) gotoIndex = gotoUsers.length;
  45. gotoIndex--;
  46. }
  47. camX = gotoUsers[gotoIndex].x - player.x;
  48. camY = gotoUsers[gotoIndex].y - player.y;
  49. }
  50.  
  51. window.gotoRight = function() {
  52. if (!gotoUsers.length) return;
  53.  
  54. if (camX == gotoUsers[gotoIndex].x - player.x && camY == gotoUsers[gotoIndex].y - player.y) {
  55. if (gotoIndex >= gotoUsers.length - 1) gotoIndex = -1;
  56. gotoIndex++;
  57. }
  58. camX = gotoUsers[gotoIndex].x - player.x;
  59. camY = gotoUsers[gotoIndex].y - player.y;
  60. }
  61.  
  62. window.addChat = function(msg, from, color) {
  63. color = color || "#fff";
  64. var b = document.createElement("li");
  65. b.className = "chatother";
  66. b.innerHTML = '<span style="color:' + color + '">[' + from + ']</span> <span class="chatText">' + msg + "</span>";
  67. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  68. chatList.appendChild(b)
  69. }
  70.  
  71. window.resetCamera = function() { // Override
  72. camX = camXS = camY = camYS = 0;
  73. cameraKeys = {
  74. l: 0,
  75. r: 0,
  76. u: 0,
  77. d: 0
  78. }
  79.  
  80. if (socket) {
  81. socket.removeAllListeners("l")
  82. socket.on("l", function(a) {
  83. var d = "", c = 1, b = 0;
  84. for (; b < a.length;) {
  85. d += "<div class='leaderboardItem' onclick=goto2(" + a[b] + ");><div style='display:inline-block;float:left;' class='whiteText'>" + c + ".</div> <div class='" + (player && a[b] == player.sid ? "leaderYou" : "leader") + "'>" + a[b + 1] + "</div><div class='scoreText'>" + a[b + 2] + "</div></div>", c++, b += 3;
  86. }
  87. leaderboardList.innerHTML = d
  88. });
  89. }
  90. }
  91.  
  92.  
  93.  
  94. window.addChatLine = function(a, d, c) {
  95. if (player) {
  96. var b = getUserBySID(a);
  97. if (c || 0 <= b) {
  98. var g = c ? "SERVER" : users[b].name;
  99. c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
  100. player.sid == a && (c = "#fff");
  101. b = document.createElement("li");
  102. b.className = player.sid == a ? "chatme" : "chatother";
  103.  
  104. b.innerHTML = '<span style="color:' + c + '" onclick=goto2(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
  105. 10 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  106. chatList.appendChild(b)
  107. }
  108. }
  109. }
  110.  
  111. window.addEventListener("keyup", function(a) {
  112. a = a.keyCode ? a.keyCode : a.which;
  113. if (a === 190) {
  114. window.gotoRight()
  115. } else if (a === 188) {
  116. window.gotoLeft();
  117. }
  118.  
  119. });