Blubbled's UI Mod v1.3

Adds some QoL features, such as always showing kill count, green health bar, etc

  1. // ==UserScript==
  2. // @name Blubbled's UI Mod v1.3
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Adds some QoL features, such as always showing kill count, green health bar, etc
  6. // @author Blubbled
  7. // @match https://suroi.io/*
  8. // @grant none
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12.  
  13. function periodicallyShowKillCounter() {
  14. showKillCounter();
  15. setTimeout(periodicallyShowKillCounter, 200);
  16. }
  17.  
  18. function showKillCounter() {
  19. var killCounter = document.getElementById('kill-counter');
  20. if (killCounter) {
  21. killCounter.style.display = 'flex';
  22. killCounter.style.alignItems = 'center';
  23. var skullIcon = killCounter.querySelector('img');
  24. if (skullIcon) {
  25. skullIcon.style.marginRight = '5px';
  26. }
  27. var counterText = killCounter.querySelector('.counter-text');
  28. if (counterText) {
  29. counterText.style.minWidth = '30px';
  30. }
  31. }
  32. }
  33.  
  34. function addAdditionalUI() {
  35. var additionalText = document.createElement('h1');
  36. additionalText.textContent = "Technical UI pack by Blubbled ";
  37. var joinLink = document.createElement('a');
  38. joinLink.textContent = "[JOIN ZESK]";
  39. joinLink.href = "https://discord.gg/msNbP9Nt2r";
  40. joinLink.style.color = 'blue';
  41. joinLink.style.textDecoration = 'underline';
  42. joinLink.style.marginLeft = '5px';
  43. additionalText.appendChild(joinLink);
  44. additionalText.style.position = 'fixed';
  45. additionalText.style.top = '10px';
  46. additionalText.style.right = '10px';
  47. additionalText.style.color = '#ffffff';
  48. additionalText.style.zIndex = '9999';
  49. additionalText.style.display = 'none';
  50. document.body.appendChild(additionalText);
  51.  
  52. var masterVolumeSlider = document.getElementById('slider-master-volume');
  53. var sfxVolumeSlider = document.getElementById('slider-sfx-volume');
  54. var musicVolumeSlider = document.getElementById('slider-music-volume');
  55. var uiScaleSlider = document.getElementById('slider-ui-scale');
  56. var minimapTransparencySlider = document.getElementById('slider-minimap-transparency');
  57. var bigMapTransparencySlider = document.getElementById('slider-big-map-transparency');
  58.  
  59. if (masterVolumeSlider && sfxVolumeSlider && musicVolumeSlider && uiScaleSlider && minimapTransparencySlider && bigMapTransparencySlider) {
  60. masterVolumeSlider.step = 0.01;
  61. sfxVolumeSlider.step = 0.01;
  62. musicVolumeSlider.step = 0.01;
  63. uiScaleSlider.step = 0.01;
  64. minimapTransparencySlider.step = 0.01;
  65. bigMapTransparencySlider.step = 0.01;
  66. }
  67. }
  68.  
  69. function replaceWithHeader() {
  70. var customHeader = document.createElement('h1');
  71. customHeader.textContent = "Technical UI pack by Blubbled ";
  72. var joinLink = document.createElement('a');
  73. joinLink.textContent = "[JOIN ZESK]";
  74. joinLink.href = "https://discord.gg/msNbP9Nt2r";
  75. joinLink.style.color = 'blue';
  76. joinLink.style.textDecoration = 'underline';
  77. joinLink.style.marginLeft = '5px'; // Adjust spacing as needed
  78. customHeader.appendChild(joinLink);
  79. customHeader.style.position = 'fixed';
  80. customHeader.style.top = '10px';
  81. customHeader.style.right = '10px';
  82. customHeader.style.color = '#ffffff';
  83. customHeader.style.zIndex = '9999';
  84. var elementToReplace = document.querySelector('a[href="./changelog/"][target="_blank"][rel="noopener noreferrer"]');
  85. if (elementToReplace) {
  86. elementToReplace.parentNode.replaceChild(customHeader, elementToReplace);
  87. }
  88. }
  89.  
  90. function updateHealthBarColor() {
  91. var healthBar = document.getElementById('health-bar');
  92. var healthPercentage = document.getElementById('health-bar-percentage');
  93. var percentage = parseInt(healthPercentage.textContent);
  94.  
  95. var colorPicker = document.getElementById('health-bar-color');
  96. var selectedColor = colorPicker.value;
  97.  
  98. var degradationColorPicker = document.getElementById('health-bar-degradation-color');
  99. var degradationColor = degradationColorPicker.value;
  100.  
  101. var redValue = Math.round((100 - percentage) * 2.55);
  102. var blendFactor = percentage / 100;
  103. var finalRed = Math.round((1 - blendFactor) * parseInt(degradationColor.substr(1, 2), 16) + blendFactor * parseInt(selectedColor.substr(1, 2), 16));
  104. var finalGreen = Math.round((1 - blendFactor) * parseInt(degradationColor.substr(3, 2), 16) + blendFactor * parseInt(selectedColor.substr(3, 2), 16));
  105. var finalBlue = Math.round((1 - blendFactor) * parseInt(degradationColor.substr(5, 2), 16) + blendFactor * parseInt(selectedColor.substr(5, 2), 16));
  106. var updatedColor = 'rgb(' + finalRed + ',' + finalGreen + ',' + finalBlue + ')';
  107. healthBar.style.backgroundColor = updatedColor;
  108. }
  109. function saveSettings() {
  110. var healthBarColor = document.getElementById('health-bar-color').value;
  111. var healthBarDegradationColor = document.getElementById('health-bar-degradation-color').value;
  112. localStorage.setItem('healthBarColor', healthBarColor);
  113. localStorage.setItem('healthBarDegradationColor', healthBarDegradationColor);
  114. }
  115.  
  116. // Function to load settings from localStorage
  117. function loadSettings() {
  118. var healthBarColor = localStorage.getItem('healthBarColor');
  119. var healthBarDegradationColor = localStorage.getItem('healthBarDegradationColor');
  120. if (healthBarColor) {
  121. document.getElementById('health-bar-color').value = healthBarColor;
  122. }
  123. if (healthBarDegradationColor) {
  124. document.getElementById('health-bar-degradation-color').value = healthBarDegradationColor;
  125. }
  126. }
  127.  
  128.  
  129. var settingsTabsContainer = document.getElementById('settings-tabs-container');
  130. var modSettingsTabButton = document.createElement('button');
  131. modSettingsTabButton.className = 'tab';
  132. modSettingsTabButton.id = 'tab-mod-settings';
  133. modSettingsTabButton.innerHTML = '<i class="fa-solid fa-gear"></i>Mod Settings';
  134. settingsTabsContainer.querySelector('#settings-tab-bar').appendChild(modSettingsTabButton);
  135.  
  136. var modSettingsTabContent = document.createElement('div');
  137. modSettingsTabContent.className = 'tab-content';
  138. modSettingsTabContent.id = 'tab-mod-settings-content';
  139. modSettingsTabContent.style.display = 'none';
  140.  
  141. var modSettingsContent = document.createElement('div');
  142.  
  143. var healthBarColorSetting = document.createElement('div');
  144. healthBarColorSetting.className = 'modal-item';
  145. healthBarColorSetting.style.marginBottom = '25px';
  146. healthBarColorSetting.innerHTML = `
  147. <label>
  148. <span class="setting-title">Health bar color</span>
  149. <input type="color" id="health-bar-color" value="#FFFFFF"> <!-- Default color: white -->
  150. </label>
  151. `;
  152. modSettingsContent.appendChild(healthBarColorSetting);
  153.  
  154. var healthBarDegradationColorSetting = document.createElement('div');
  155. healthBarDegradationColorSetting.className = 'modal-item';
  156. healthBarDegradationColorSetting.style.marginBottom = '10px';
  157. healthBarDegradationColorSetting.innerHTML = `
  158. <label>
  159. <span class="setting-title">Health bar degradation color</span>
  160. <input type="color" id="health-bar-degradation-color" value="#FF0000"> <!-- Default color: red -->
  161. </label>`;
  162. modSettingsContent.appendChild(healthBarDegradationColorSetting);
  163.  
  164. modSettingsTabContent.appendChild(modSettingsContent);
  165. settingsTabsContainer.querySelector('#settings-tabs').appendChild(modSettingsTabContent);
  166.  
  167.  
  168.  
  169. var healthBarSettings = document.querySelectorAll('#health-bar-color, #health-bar-degradation-color');
  170. healthBarSettings.forEach(function(setting) {
  171. setting.addEventListener('input', function() {
  172. updateHealthBarColor();
  173. saveSettings();
  174. });
  175. });
  176.  
  177. function toggleUncappedFPS(enabled) {
  178. if (enabled) {
  179. window.requestAnimationFrame = function(callback) {
  180. return setTimeout(callback, 1);
  181. };
  182. } else {
  183. window.requestAnimationFrame = function(callback) {
  184. return setTimeout(callback, 1000 / 60);
  185. };
  186. }
  187. }
  188.  
  189.  
  190. var uncappedFPSEnabled = localStorage.getItem('uncappedFPSEnabled') === 'true';
  191. toggleUncappedFPS(uncappedFPSEnabled);
  192.  
  193.  
  194. function updateUncappedFPSSetting(enabled) {
  195. localStorage.setItem('uncappedFPSEnabled', enabled);
  196. toggleUncappedFPS(enabled);
  197. }
  198.  
  199.  
  200. function createUncappedFPSSetting() {
  201. var uncappedFPSSetting = document.createElement('div');
  202. uncappedFPSSetting.className = 'modal-item checkbox-setting';
  203. uncappedFPSSetting.style.marginBottom = '10px';
  204. uncappedFPSSetting.innerHTML = `
  205. <label>
  206. <span class="setting-title" style="margin-right: 10px;">Uncapped FPS</span>
  207. <input type="checkbox" id="toggle-uncapped-fps" ${uncappedFPSEnabled ? 'checked' : ''} style="margin-left: auto; margin-right: -40px; ">
  208. </label>
  209. `;
  210. uncappedFPSSetting.querySelector('#toggle-uncapped-fps').addEventListener('change', function() {
  211. updateUncappedFPSSetting(this.checked);
  212. });
  213. return uncappedFPSSetting;
  214. }
  215.  
  216.  
  217. modSettingsContent.appendChild(createUncappedFPSSetting());
  218.  
  219. var graphicsSettingsTabContent = document.getElementById('tab-graphics-content');
  220. graphicsSettingsTabContent.appendChild(createUncappedFPSSetting());
  221.  
  222.  
  223. showKillCounter();
  224. addAdditionalUI();
  225. updateHealthBarColor();
  226. loadSettings();
  227. createUncappedFPSSetting()
  228. var healthPercentage = document.getElementById('health-bar-percentage');
  229. healthPercentage.addEventListener('DOMSubtreeModified', updateHealthBarColor);
  230.  
  231. periodicallyShowKillCounter();
  232. document.addEventListener('DOMContentLoaded', addAdditionalUI);
  233. window.addEventListener('popstate', showKillCounter);
  234. replaceWithHeader();
  235. })();