Lag Reducer Mod Menu

MultiAdvanced script to help play video games, multiple other things! If there are any bugs comment that, ctrl key to open/close and more!

当前为 2024-01-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Lag Reducer Mod Menu
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  5. // @description MultiAdvanced script to help play video games, multiple other things! If there are any bugs comment that, ctrl key to open/close and more!
  6. // @author You
  7. // @include *
  8. // @license none
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const modMenuId = 'lagReducerModMenu';
  16. const defaultLanguage = 'en';
  17.  
  18. const translations = {
  19. en: {
  20. title: 'Lag Reducer Mod Menu',
  21. lagLevelLabel: 'Select Lag Reduction Level:',
  22. lazyLoadLabel: 'Lazy Load:',
  23. targetFPSLabel: 'Target FPS for Booster:',
  24. targetPingLabel: 'Target Ping for Reducer:',
  25. editorPreferences: 'Editor Preferences:',
  26. performanceInfoLabel: 'Last execution time:',
  27. resetSettings: 'Reset Settings'
  28. },
  29. es: {
  30. title: 'Menú de Modificación de Reducción de Lag',
  31. lagLevelLabel: 'Seleccionar Nivel de Reducción de Lag:',
  32. lazyLoadLabel: 'Carga Perezosa:',
  33. targetFPSLabel: 'Objetivo de FPS para el Impulsor:',
  34. targetPingLabel: 'Objetivo de Ping para el Reductor:',
  35. editorPreferences: 'Preferencias del Editor:',
  36. performanceInfoLabel: 'Tiempo de ejecución:',
  37. resetSettings: 'Restablecer Configuración'
  38. }
  39. // Add more languages as needed
  40. };
  41.  
  42. function applyLagReduction(lagLevel, lazyLoad, targetFPS, targetPing, editorPreferences) {
  43. const startTime = performance.now();
  44.  
  45. // Simulate lag reduction based on the lag level
  46. const lagReductionFactor = lagLevel / 100;
  47.  
  48. // Simulate lazy loading if enabled
  49. if (lazyLoad) {
  50. setTimeout(() => {
  51. console.log(`Lazy load applied: lag reduction ${lagReductionFactor}`);
  52. }, 1000);
  53. }
  54.  
  55. // Simulate FPS booster based on target FPS
  56. const currentFPS = detectCurrentFPS();
  57. console.log(`Current FPS: ${currentFPS}`);
  58.  
  59. if (currentFPS <= targetFPS) {
  60. const newLagReduction = lagReductionFactor * (targetFPS / currentFPS);
  61. console.log(`Adjusted lag reduction for better FPS: ${newLagReduction}`);
  62. }
  63.  
  64. // Simulate ping reducer based on target ping
  65. const currentPing = detectCurrentPing();
  66. console.log(`Current Ping: ${currentPing}`);
  67.  
  68. if (currentPing >= targetPing) {
  69. const newLagReduction = lagReductionFactor * (targetPing / currentPing);
  70. console.log(`Adjusted lag reduction for better Ping: ${newLagReduction}`);
  71. }
  72.  
  73. // Simulate editor preferences
  74. if (editorPreferences) {
  75. console.log('Applying editor preferences:', editorPreferences);
  76. }
  77.  
  78. // Simulate a delay
  79. setTimeout(() => {
  80. console.log(`Lag reduction applied: ${lagReductionFactor}`);
  81. const endTime = performance.now();
  82. const executionTime = endTime - startTime;
  83. updatePerformanceInfo('lagReduction', executionTime);
  84. }, 1000 * lagReductionFactor);
  85. }
  86.  
  87. function detectCurrentFPS() {
  88. return Math.random() * 60;
  89. }
  90.  
  91. function detectCurrentPing() {
  92. return Math.random() * 100;
  93. }
  94.  
  95. function applyLazyLoad() {
  96. const startTime = performance.now();
  97.  
  98. // Simulate lazy loading
  99. setTimeout(() => {
  100. console.log('Lazy load applied');
  101. const endTime = performance.now();
  102. const executionTime = endTime - startTime;
  103. updatePerformanceInfo('lazyLoad', executionTime);
  104. }, 1000);
  105. }
  106.  
  107. function applyFPSBooster(targetFPS) {
  108. const startTime = performance.now();
  109.  
  110. // Simulate detecting current FPS
  111. const currentFPS = detectCurrentFPS();
  112. console.log(`Current FPS: ${currentFPS}`);
  113.  
  114. if (currentFPS <= targetFPS) {
  115. console.log(`Adjusted for better FPS`);
  116. }
  117.  
  118. // Simulate a delay
  119. setTimeout(() => {
  120. const endTime = performance.now();
  121. const executionTime = endTime - startTime;
  122. updatePerformanceInfo('fpsBooster', executionTime);
  123. }, 1000);
  124. }
  125.  
  126. function applyPingReducer(targetPing) {
  127. const startTime = performance.now();
  128.  
  129. // Simulate detecting current ping
  130. const currentPing = detectCurrentPing();
  131. console.log(`Current Ping: ${currentPing}`);
  132.  
  133. if (currentPing >= targetPing) {
  134. console.log(`Adjusted for better Ping`);
  135. }
  136.  
  137. // Simulate a delay
  138. setTimeout(() => {
  139. const endTime = performance.now();
  140. const executionTime = endTime - startTime;
  141. updatePerformanceInfo('pingReducer', executionTime);
  142. }, 1000);
  143. }
  144.  
  145. function updatePerformanceInfo(operation, executionTime) {
  146. const performanceInfoElement = document.getElementById('performanceInfo');
  147. if (performanceInfoElement) {
  148. const operationLabel = translations[getLanguage()].performanceInfoLabel + ` (${operation}):`;
  149. performanceInfoElement.innerHTML = `<div>${operationLabel}</div><div>${executionTime.toFixed(2)} ms</div>`;
  150. }
  151. }
  152.  
  153. function saveLagLevel(lagLevel) {
  154. localStorage.setItem('lagLevel', lagLevel);
  155. }
  156.  
  157. function loadLagLevel() {
  158. return localStorage.getItem('lagLevel') || 50;
  159. }
  160.  
  161. function saveLazyLoadState(lazyLoad) {
  162. localStorage.setItem('lazyLoad', lazyLoad);
  163. }
  164.  
  165. function loadLazyLoadState() {
  166. return localStorage.getItem('lazyLoad') === 'true';
  167. }
  168.  
  169. function saveTargetFPS(targetFPS) {
  170. localStorage.setItem('targetFPS', targetFPS);
  171. }
  172.  
  173. function loadTargetFPS() {
  174. return parseInt(localStorage.getItem('targetFPS')) || 30;
  175. }
  176.  
  177. function saveTargetPing(targetPing) {
  178. localStorage.setItem('targetPing', targetPing);
  179. }
  180.  
  181. function loadTargetPing() {
  182. return parseInt(localStorage.getItem('targetPing')) || 50;
  183. }
  184.  
  185. function saveEditorPreferences(editorPreferences) {
  186. localStorage.setItem('editorPreferences', JSON.stringify(editorPreferences));
  187. }
  188.  
  189. function loadEditorPreferences() {
  190. const storedPreferences = localStorage.getItem('editorPreferences');
  191. return storedPreferences ? JSON.parse(storedPreferences) : null;
  192. }
  193.  
  194. function setLanguage(language) {
  195. localStorage.setItem('userLanguage', language);
  196. }
  197.  
  198. function getLanguage() {
  199. return localStorage.getItem('userLanguage') || defaultLanguage;
  200. }
  201.  
  202. function resetSettings() {
  203. localStorage.removeItem('lagLevel');
  204. localStorage.removeItem('lazyLoad');
  205. localStorage.removeItem('targetFPS');
  206. localStorage.removeItem('targetPing');
  207. localStorage.removeItem('editorPreferences');
  208. location.reload();
  209. }
  210.  
  211. function createModMenu() {
  212. const existingMenu = document.getElementById(modMenuId);
  213. if (existingMenu) {
  214. existingMenu.remove();
  215. }
  216.  
  217. const modMenu = document.createElement('div');
  218. modMenu.id = modMenuId;
  219. modMenu.style.cssText = `
  220. position: fixed;
  221. top: 10px;
  222. left: 10px;
  223. padding: 10px;
  224. background: #333;
  225. border: 1px solid #ccc;
  226. color: #fff;
  227. z-index: 9999;
  228. font-family: Arial, sans-serif;
  229. `;
  230. modMenu.innerHTML = `
  231. <h2>${translations[getLanguage()].title}</h2>
  232. <label for="lagLevel">${translations[getLanguage()].lagLevelLabel}</label>
  233. <input type="range" id="lagLevel" min="1" max="100" value="${loadLagLevel()}">
  234. <span id="lagValue">${loadLagLevel()}</span>
  235. <br>
  236. <label for="lazyLoad">${translations[getLanguage()].lazyLoadLabel}</label>
  237. <input type="checkbox" id="lazyLoad" ${loadLazyLoadState() ? 'checked' : ''}>
  238. <br>
  239. <label for="targetFPS">${translations[getLanguage()].targetFPSLabel}</label>
  240. <input type="number" id="targetFPS" min="1" max="60" value="${loadTargetFPS()}" style="margin-right: 20px;">
  241. <label for="targetPing">${translations[getLanguage()].targetPingLabel}</label>
  242. <input type="number" id="targetPing" min="1" max="200" value="${loadTargetPing()}">
  243. <br>
  244. <label for="editorPreferences">${translations[getLanguage()].editorPreferences}</label>
  245. <input type="text" id="editorPreferences" value="${loadEditorPreferences() || ''}" style="width: 80%;">
  246. <br>
  247. <button id="resetSettings">${translations[getLanguage()].resetSettings}</button>
  248. <div id="performanceInfo" style="margin-top: 10px;"></div>
  249. `;
  250. document.body.appendChild(modMenu);
  251.  
  252. const lagLevelInput = document.getElementById('lagLevel');
  253. const lagValueSpan = document.getElementById('lagValue');
  254. const lazyLoadCheckbox = document.getElementById('lazyLoad');
  255. const targetFPSInput = document.getElementById('targetFPS');
  256. const targetPingInput = document.getElementById('targetPing');
  257. const editorPreferencesInput = document.getElementById('editorPreferences');
  258.  
  259. lagLevelInput.addEventListener('input', () => {
  260. const lagValue = lagLevelInput.value;
  261. lagValueSpan.textContent = lagValue;
  262. saveLagLevel(lagValue);
  263.  
  264. applyLagReduction(
  265. parseInt(lagValue, 10),
  266. lazyLoadCheckbox.checked,
  267. parseInt(targetFPSInput.value, 10),
  268. parseInt(targetPingInput.value, 10),
  269. editorPreferencesInput.value
  270. );
  271. });
  272.  
  273. lazyLoadCheckbox.addEventListener('change', () => {
  274. saveLazyLoadState(lazyLoadCheckbox.checked);
  275.  
  276. if (lazyLoadCheckbox.checked) {
  277. applyLazyLoad();
  278. }
  279. });
  280.  
  281. targetFPSInput.addEventListener('input', () => {
  282. saveTargetFPS(targetFPSInput.value);
  283. applyFPSBooster(parseInt(targetFPSInput.value, 10));
  284. });
  285.  
  286. targetPingInput.addEventListener('input', () => {
  287. saveTargetPing(targetPingInput.value);
  288. applyPingReducer(parseInt(targetPingInput.value, 10));
  289. });
  290.  
  291. editorPreferencesInput.addEventListener('input', () => {
  292. saveEditorPreferences(editorPreferencesInput.value);
  293. });
  294.  
  295. const resetSettingsButton = document.getElementById('resetSettings');
  296. if (resetSettingsButton) {
  297. resetSettingsButton.addEventListener('click', resetSettings);
  298. }
  299. }
  300.  
  301. document.addEventListener('keydown', (event) => {
  302. if (event.ctrlKey && event.key === 'Control') {
  303. const modMenu = document.getElementById(modMenuId);
  304. if (modMenu) {
  305. modMenu.style.display = modMenu.style.display === 'none' ? 'block' : 'none';
  306. } else {
  307. createModMenu();
  308. }
  309. }
  310. });
  311.  
  312. createModMenu();
  313. })();