Player-List Mod (Draggable) | Shell Shockers | flyg0n LiTe

Adds a draggable player list to the shell shockers game UI. Shows paused players and players hp.

بۇ قوليازمىنى قاچىلاش؟
ئاپتورنىڭ تەۋسىيەلىگەن قوليازمىسى

سىز بەلكىم Health-Bar Mod | Shell Shockers | flygOn LiTe نى ياقتۇرۇشىڭىز مۇمكىن.

بۇ قوليازمىنى قاچىلاش
  1. // ==UserScript==
  2. // @name Player-List Mod (Draggable) | Shell Shockers | flyg0n LiTe
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.8
  5. // @description Adds a draggable player list to the shell shockers game UI. Shows paused players and players hp.
  6. // @author flyg0n LiTe
  7. // @match https://shellshock.io/*
  8. // @match https://mathactivity.xyz/*
  9. // @match https://mathdrills.life/*
  10. // @icon https://www.berrywidgets.com/assets/health-bar2.png
  11. // @grant GM_addStyle
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. GM_addStyle(`
  19. #playerHealthContainer {
  20. position: fixed;
  21. top: 0;
  22. left: 0;
  23. z-index: 1000;
  24. color: white;
  25. font-size: 14px;
  26. background-color: #DB5A48;
  27. font-family: 'Kanit', sans-serif;
  28. padding: 5px;
  29. cursor: grab;
  30. margin: 5px;
  31. }
  32. .changeColor {
  33. position: absolute;
  34. top: 0;
  35. right: 0;
  36. z-index: 1001;
  37. background: none;
  38. border: none;
  39. color: white;
  40. font-size: 20px;
  41. cursor: pointer;
  42. outline: none;
  43. }
  44. `);
  45.  
  46. // Add a container to display the health
  47. const playerHealthContainer = document.createElement('div');
  48. playerHealthContainer.id = 'playerHealthContainer';
  49. document.body.appendChild(playerHealthContainer);
  50.  
  51. function sortByHealth(a, b) {
  52. if (a.hp > b.hp) {
  53. return -1;
  54. }
  55. if (a.hp < b.hp) {
  56. return 1;
  57. }
  58. return 0;
  59. }
  60.  
  61. function updateHealthDisplay() {
  62. let playersArray = Array.from(window.players.values());
  63. playersArray.sort(sortByHealth);
  64.  
  65. let healthInfo = '';
  66. playersArray.forEach((player) => {
  67. healthInfo += `${player.name}: ${player.hp === 0 ? 'Paused' : (player.hp).toFixed(2) + ' HP'}<br>`;
  68. });
  69. playerHealthContainer.innerHTML = healthInfo;
  70. }
  71.  
  72. // Store player data
  73. window.players = new Map();
  74.  
  75. // Intercept push method to store player data
  76. const originalPush = Array.prototype.push;
  77. Array.prototype.push = function(data) {
  78. try {
  79. if (arguments[0].player && arguments[0].id) {
  80. const playerProxy = new Proxy(arguments[0].player, {
  81. set: (target, property, value) => {
  82. target[property] = value;
  83. if (property === 'hp') {
  84. updateHealthDisplay();
  85. }
  86. return true;
  87. },
  88. });
  89. window.players.set(playerProxy.id, playerProxy);
  90. updateHealthDisplay();
  91. }
  92. } catch (e) {
  93. console.log(e);
  94. }
  95. return originalPush.apply(this, arguments);
  96. };
  97.  
  98. // Add color picker
  99. const colorPicker = document.createElement('input');
  100. colorPicker.type = 'color';
  101. colorPicker.style.display = 'none';
  102. colorPicker.onchange = () => {
  103. playerHealthContainer.style.backgroundColor = colorPicker.value;
  104. };
  105. document.body.appendChild(colorPicker);
  106.  
  107. // Add change color button
  108. const changeColorBtn = document.createElement('button');
  109. changeColorBtn.className = 'changeColor';
  110. changeColorBtn.innerHTML = '&#9881;';
  111. changeColorBtn.onclick = () => {
  112. colorPicker.click();
  113. };
  114. document.body.appendChild(changeColorBtn);
  115.  
  116. // Load Google Fonts
  117. const googleFontLink = document.createElement('link');
  118. googleFontLink.href = 'https://fonts.googleapis.com/css2?family=Kanit&display=swap';
  119. googleFontLink.rel = 'stylesheet';
  120. document.head.appendChild(googleFontLink);
  121. // Make the playerHealthContainer draggable
  122. playerHealthContainer.addEventListener('mousedown', (event) => {
  123. event.preventDefault();
  124. const offsetX = event.clientX - playerHealthContainer.getBoundingClientRect().left;
  125. const offsetY = event.clientY - playerHealthContainer.getBoundingClientRect().top;
  126.  
  127. const onMouseMove = (event) => {
  128. playerHealthContainer.style.left = `${event.clientX - offsetX}px`;
  129. playerHealthContainer.style.top = `${event.clientY - offsetY}px`;
  130. };
  131.  
  132. const onMouseUp = () => {
  133. document.removeEventListener('mousemove', onMouseMove);
  134. document.removeEventListener('mouseup', onMouseUp);
  135. };
  136.  
  137. document.addEventListener('mousemove', onMouseMove);
  138. document.addEventListener('mouseup', onMouseUp);
  139. });
  140. })();
  141.  
  142.