Chat Scroll - Alert - Instafind

chat

目前為 2023-05-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Chat Scroll - Alert - Instafind
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description chat
  6. // @author Neutrox
  7. // @match http://bloble.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //instafind//
  12. window.chatListWrapper.style.pointerEvents = 'auto';
  13. window.leaderboardList.style.pointerEvents = 'auto';
  14.  
  15. window.goToBase = function(id) {
  16. let xX = [];
  17. let yY = [];
  18. for(let i = 0; i < users.length; i++){
  19. if(users[i].sid == id){
  20. xX.push(users[i].x)
  21. yY.push(users[i].y)
  22. }
  23. }
  24. if (xX.length > 0 && yY.length > 0) {
  25. camX = xX[0] - player.x;
  26. camY = yY[0] - player.y;
  27. }
  28. }
  29.  
  30. window.addChatLine = (a, d, c) => {
  31. if (player) {
  32. var b = getUserBySID(a);
  33. if (c || 0 <= b) {
  34. var g = c ? "SERVER" : users[b].name;
  35. c = c ? "#fff" : playerColors[users[b].color] ? playerColors[users[b].color] : playerColors[0];
  36. player.sid == a && (c = "#fff");
  37. b = document.createElement("li");
  38. b.className = player.sid == a ? "chatme" : "chatother";
  39. b.innerHTML = '<span style="color:' + c + '" onclick=goToBase(' + a + ');>[' + g + ']</span> <span class="chatText">' + d + "</span>";
  40. 25 < chatList.childNodes.length && chatList.removeChild(chatList.childNodes[0]);
  41. chatList.appendChild(b)
  42. }
  43. }
  44. }
  45.  
  46. window.addChat = (msg, cor) => {
  47. var b = document.createElement("li");
  48. b.innerHTML = '<span class="chatText" style="color: ' + cor + ';">' + msg + "</span>";
  49. chatList.appendChild(b)
  50. }
  51.  
  52. //scroll chat//
  53. const chatElement = document.getElementById('chatList');
  54.  
  55. chatElement.addEventListener('wheel', (event) => {
  56. event.stopPropagation();
  57. });
  58.  
  59. var css2 = document.createElement("style")
  60. css2.innerText = `
  61. #chatListWrapper {
  62. background-color: rgba(60, 60, 60, 0.6);
  63. border-radius: 4px 4px 0px 0px;
  64. height: 215px;
  65. overflow: visible;
  66. }
  67. #chatList{
  68. width: 100%;
  69. font-family: "regularF";
  70. padding: 8px;
  71. margin: 0;
  72. list-style: none;
  73. box-sizing: border-box;
  74. color: #fff;
  75. overflow: hidden;
  76. word-wrap: break-word;
  77. position: absolute;
  78. bottom: 30px;
  79. font-size: 16px;
  80. line-height: 23px;
  81. overflow-x: hidden;
  82. overflow-y: scroll;
  83. height: 88%;\n\
  84. }
  85. ::-webkit-scrollbar {
  86. width: 10px;
  87. background-color: #00000000;
  88. }
  89.  
  90. ::-webkit-scrollbar-thumb {
  91. background-color: #00000080;
  92. }
  93. `
  94. document.head.appendChild(css2)
  95.  
  96. var chatList = document.querySelector('#chatList');
  97.  
  98. var observer = new MutationObserver(function(mutations) {
  99. var newElementsAdded = false;
  100. mutations.forEach(function(mutation) {
  101. if (mutation.addedNodes.length > 0) {
  102. newElementsAdded = true;
  103. }
  104. });
  105.  
  106. if (newElementsAdded) {
  107. chatrolagem();
  108. }
  109. });
  110.  
  111. var observerConfig = { childList: true };
  112. observer.observe(chatList, observerConfig);
  113.  
  114. function chatrolagem() {
  115. var chatList = document.querySelector('#chatList');
  116. var isNearBottom = chatList.scrollHeight - chatList.clientHeight - chatList.scrollTop <= 150;
  117. if (isNearBottom) {
  118. chatList.scrollTop = chatList.scrollHeight - chatList.clientHeight;
  119. }
  120. }
  121.  
  122. window.setupSocket = () => {
  123. socket.on("connect_error", function() {lobbyURLIP ? kickPlayer("Connection failed. Please check your lobby ID") : kickPlayer("Connection failed. Check your internet and firewall settings")});
  124. socket.on("disconnect", function(a) {kickPlayer("Disconnected.")});
  125. socket.on("error", function(a) {kickPlayer("Disconnected. The server may have updated.")});
  126. socket.on("kick", function(a) {kickPlayer(a)});
  127. socket.on("lk", function(a) {partyKey = a});
  128. socket.on("spawn", function() { gameState = 1; unitList = share.getUnitList(); resetCamera(); toggleMenuUI(!1); toggleGameUI(!0); updateUnitList(); player.upgrades = share.getBaseUpgrades();mainCanvas.focus()});
  129. socket.on("gd", function(a) {gameData = a});
  130. socket.on("mpd", function(a) {mapBounds = a});
  131. socket.on("ch", function(a, d, c) {addChatLine(a, d, c)});
  132. socket.on("setUser", function(a, d) { if (a && a[0]) { var c = getUserBySID(a[0]), b = { sid: a[0], name: a[1], iName: "Headquarters", dead: !1, color: a[2], size: a[3], startSize: a[4], x: a[5], y: a[6], buildRange: a[7], gridIndex: a[8], spawnProt: a[9], skin: a[10], desc: "Base of operations of " + a[1], kills: 0, typeName: "Base" }; null != c ? (users[c] = b, d && (player = users[c])) : (users.push(b), d && (player = users[users.length - 1]));}});
  133. socket.on("klUser", function(a) {var d = getUserBySID(a);null != d && (users[d].dead = !0);player && player.sid == a && (hideMainMenuText(), leaveGame())});
  134. socket.on("delUser", function(a) {a = getUserBySID(a);null != a && users.splice(a, 1)});
  135. socket.on("au", function(a) { a && (units.push({ id: a[0], owner: a[1], uPath: a[2] || 0, type: a[3] || 0, color: a[4] || 0, paths: a[5], x: a[6] || 0, sX: a[6] || 0, y: a[7] || 0, sY: a[7] || 0, dir: a[8] || 0, dst: UTILS.roundToTwo(UTILS.getDistance(player.x, player.y, a[6], a[7])), turRot: a[8] || 0, speed: a[9] || 0, renderIndex: a[10] || 0, turretIndex: a[11] || 0, range: a[12] || 0, cloak: a[13] || 0 }), units[units.length - 1].speed && (units[units.length - 1].startTime = window.performance.now()), a = getUnitFromPath(units[units.length - 1].uPath)) && (units[units.length - 1].size = a.size, units[units.length - 1].shape = a.shape, units[units.length - 1].layer = a.layer, units[units.length - 1].renderIndex || (units[units.length - 1].renderIndex = a.renderIndex), units[units.length - 1].range || (units[units.length - 1].range = a.range), units[units.length - 1].turretIndex || (units[units.length - 1].turretIndex = a.turretIndex), units[units.length - 1].iSize = a.iSize) });
  136. socket.on("spa", function(a, d, c, b) { a = getUnitById(a); if (null != a) { var g = UTILS.getDistance(d, c, units[a].x || d, units[a].y || c); 300 > g && g ? (units[a].interpDst = g, units[a].interpDstS = g, units[a].interpDir = UTILS.getDirection(d, c, units[a].x || d, units[a].y || c)) : (units[a].interpDst = 0, units[a].interpDstS = 0, units[a].interpDir = 0, units[a].x = d, units[a].y = c); units[a].interX = 0; units[a].interY = 0; units[a].sX = units[a].x || d; units[a].sY = units[a].y || c; b[0] && (units[a].dir = b[0], units[a].turRot = b[0]); units[a].paths = b; units[a].startTime = window.performance.now()}});
  137. socket.on("uc", function(a, d) {unitList && (unitList[a].count = d);forceUnitInfoUpdate = !0});
  138. socket.on("uul", function(a, d) {unitList && (unitList[a].limit += d)});
  139. socket.on("rpu", function(a, d) {var c = getUnitFromPath(a);c && (c.dontShow = d, forceUnitInfoUpdate = !0)});
  140. socket.on("sp", function(a, d) { var c = getUserBySID(a); if (null != c) { users[c].spawnProt = d; var playerName = users[c].name; var playerSid = users[c].sid; var message = '<a href="#" onclick="goToBase(\'' + playerSid + '\')" style="color: ' + playerColors[users[c].color] + ';">' + playerName + '</a> left the base.'; addChat(message, playerColors[users[c].color]); } });
  141. socket.on("ab", function(a) { a && bullets.push({ x: a[0], sX: a[0], y: a[1], sY: a[1], dir: a[2], speed: a[3], size: a[4], range: a[5] }) });
  142. socket.on("uu", function(a, d) {if (void 0 != a && d) {var c = getUnitById(a);if (null != c)for (var b = 0; b < d.length;) units[c][d[b]] = d[b + 1], "dir" == d[b] && (units[c].turRot = d[b + 1]), b += 2}});
  143. socket.on("du", function(a) {a = getUnitById(a);null != a && units.splice(a, 1)});
  144. socket.on("sz", function(a, d) {var c = getUserBySID(a);null != c && (users[c].size = d)});
  145. socket.on("pt", function(a) {scoreContainer.innerHTML = "Power <span class='greyMenuText'>" + a +"/6000</span>"; player.power = a});
  146. socket.on("l", function(a) {for (var d = "", c = 1, b = 0; b < a.length;) d += "<div class='leaderboardItem' onclick=goToBase(" + 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;leaderboardList.innerHTML = d})
  147. }