Smashkarts Performance Enhancer

Improve overall game performance by disabling resource-heavy features and limiting frame rate.

  1. // ==UserScript==
  2. // @name Smashkarts Performance Enhancer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Improve overall game performance by disabling resource-heavy features and limiting frame rate.
  6. // @author You
  7. // @match *://*.smashkarts.io/*
  8. // @grant none
  9. // @run-at document-end
  10. // @license All rights reserved // <-- License added
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Disable background music
  17. function disableBackgroundMusic() {
  18. let backgroundMusic = document.querySelector('audio');
  19. if (backgroundMusic) {
  20. backgroundMusic.muted = true; // Mutes the background music
  21. }
  22. }
  23.  
  24. // Reduce or remove particle effects (if present)
  25. function disableParticles() {
  26. let particleSystems = document.querySelectorAll('.particle-system');
  27. particleSystems.forEach((system) => {
  28. system.style.display = "none"; // Hides particle systems for better performance
  29. });
  30. }
  31.  
  32. // Lower the framerate for smoother performance (limit to 30 FPS)
  33. function limitFrameRate() {
  34. let originalRequestAnimationFrame = window.requestAnimationFrame;
  35. window.requestAnimationFrame = function(callback) {
  36. setTimeout(() => {
  37. originalRequestAnimationFrame(callback);
  38. }, 1000 / 30); // Throttles the frame rate to 30fps
  39. };
  40. }
  41.  
  42. // Minimize DOM manipulation (show/hide instead of adding/removing elements)
  43. function optimizeDomManipulation() {
  44. let keyBoxes = document.querySelectorAll('.key-box');
  45. keyBoxes.forEach((box) => {
  46. box.style.transition = 'none'; // Disable transitions to improve performance
  47. });
  48. }
  49.  
  50. // Optimize key event listeners (avoid constant DOM updates)
  51. function optimizeKeyEventListeners() {
  52. let lastPressedKey = null;
  53.  
  54. document.addEventListener('keydown', function(event) {
  55. var key = event.key.toUpperCase();
  56. if (key === " ") key = "SPACE";
  57. if (key === "CONTROL") key = "CONTROL";
  58.  
  59. if (key !== lastPressedKey) {
  60. // Change color or visibility based on key press, update DOM minimally
  61. updateKeyBoxColor(key, true);
  62. lastPressedKey = key;
  63. }
  64. });
  65.  
  66. document.addEventListener('keyup', function(event) {
  67. var key = event.key.toUpperCase();
  68. if (key === " ") key = "SPACE";
  69. if (key === "CONTROL") key = "CONTROL";
  70.  
  71. if (key === lastPressedKey) {
  72. updateKeyBoxColor(key, false);
  73. lastPressedKey = null;
  74. }
  75. });
  76. }
  77.  
  78. // Update the color or visibility of keyboxes (minimized DOM update)
  79. function updateKeyBoxColor(key, isPressed) {
  80. let keyBoxes = document.querySelectorAll('.key-box');
  81. keyBoxes.forEach(function(box) {
  82. if (box.textContent === key) {
  83. if (isPressed) {
  84. box.style.backgroundColor = box.dataset.color; // Highlight key on press
  85. } else {
  86. box.style.backgroundColor = 'transparent'; // Reset background on release
  87. }
  88. }
  89. });
  90. }
  91.  
  92. // Initialize optimizations
  93. function initializeOptimizations() {
  94. disableBackgroundMusic();
  95. disableParticles();
  96. limitFrameRate();
  97. optimizeDomManipulation();
  98. optimizeKeyEventListeners();
  99. }
  100.  
  101. // Initialize once the document is fully loaded
  102. window.addEventListener('load', function() {
  103. initializeOptimizations();
  104. });
  105.  
  106. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址