您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Improve overall game performance by disabling resource-heavy features and limiting frame rate.
- // ==UserScript==
- // @name Smashkarts Performance Enhancer
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Improve overall game performance by disabling resource-heavy features and limiting frame rate.
- // @author You
- // @match *://*.smashkarts.io/*
- // @grant none
- // @run-at document-end
- // @license All rights reserved // <-- License added
- // ==/UserScript==
- (function() {
- 'use strict';
- // Disable background music
- function disableBackgroundMusic() {
- let backgroundMusic = document.querySelector('audio');
- if (backgroundMusic) {
- backgroundMusic.muted = true; // Mutes the background music
- }
- }
- // Reduce or remove particle effects (if present)
- function disableParticles() {
- let particleSystems = document.querySelectorAll('.particle-system');
- particleSystems.forEach((system) => {
- system.style.display = "none"; // Hides particle systems for better performance
- });
- }
- // Lower the framerate for smoother performance (limit to 30 FPS)
- function limitFrameRate() {
- let originalRequestAnimationFrame = window.requestAnimationFrame;
- window.requestAnimationFrame = function(callback) {
- setTimeout(() => {
- originalRequestAnimationFrame(callback);
- }, 1000 / 30); // Throttles the frame rate to 30fps
- };
- }
- // Minimize DOM manipulation (show/hide instead of adding/removing elements)
- function optimizeDomManipulation() {
- let keyBoxes = document.querySelectorAll('.key-box');
- keyBoxes.forEach((box) => {
- box.style.transition = 'none'; // Disable transitions to improve performance
- });
- }
- // Optimize key event listeners (avoid constant DOM updates)
- function optimizeKeyEventListeners() {
- let lastPressedKey = null;
- document.addEventListener('keydown', function(event) {
- var key = event.key.toUpperCase();
- if (key === " ") key = "SPACE";
- if (key === "CONTROL") key = "CONTROL";
- if (key !== lastPressedKey) {
- // Change color or visibility based on key press, update DOM minimally
- updateKeyBoxColor(key, true);
- lastPressedKey = key;
- }
- });
- document.addEventListener('keyup', function(event) {
- var key = event.key.toUpperCase();
- if (key === " ") key = "SPACE";
- if (key === "CONTROL") key = "CONTROL";
- if (key === lastPressedKey) {
- updateKeyBoxColor(key, false);
- lastPressedKey = null;
- }
- });
- }
- // Update the color or visibility of keyboxes (minimized DOM update)
- function updateKeyBoxColor(key, isPressed) {
- let keyBoxes = document.querySelectorAll('.key-box');
- keyBoxes.forEach(function(box) {
- if (box.textContent === key) {
- if (isPressed) {
- box.style.backgroundColor = box.dataset.color; // Highlight key on press
- } else {
- box.style.backgroundColor = 'transparent'; // Reset background on release
- }
- }
- });
- }
- // Initialize optimizations
- function initializeOptimizations() {
- disableBackgroundMusic();
- disableParticles();
- limitFrameRate();
- optimizeDomManipulation();
- optimizeKeyEventListeners();
- }
- // Initialize once the document is fully loaded
- window.addEventListener('load', function() {
- initializeOptimizations();
- });
- })();