Tank Trouble Booster

Boost Chrome performance for Tank Trouble game by disabling certain features

当前为 2024-06-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Tank Trouble Booster
// @namespace http://tampermonkey.net/
// @version 0.0.2
// @license      GPL-3.0
// @description Boost Chrome performance for Tank Trouble game by disabling certain features
// @author kamarov
// @match https://tanktrouble.com/*
// @grant none
// ==/UserScript==

// Disable unnecessary features
function disableFeatures() {
// Disable Chrome PDF Viewer
chrome.plugins.mv = null;

// Disable automatic tab discarding
chrome.experimental.tabDiscarding = false;

// Suspend unused tabs to free up resources
chrome.tabs.query({}, function(tabs) {
tabs.forEach(function(tab) {
if (tab.url.indexOf("tanktrouble.com") === -1) {
chrome.tabs.discard(tab.id);
}
});
});

// Reduce JavaScript timer frequency for background tabs
chrome.extension.getBackgroundPage().setTimeout(function() {
setInterval(function() {
if (document.hidden) {
// Adjust the delay interval to your preference (in milliseconds)
// Higher values reduce CPU usage but may impact real-time updates
setTimeout(function() {}, 300);
}
}, 1000);
}, 5000);

// Additional optimizations
// Disable image animations
const disableImageAnimations = () => {
const images = document.querySelectorAll("img");
images.forEach((img) => {
img.style.animation = "none";
});
};
    // Disable CSS animations
const disableCSSAnimations = () => {
const stylesheets = document.styleSheets;
stylesheets.forEach((sheet) => {
try {
const rules = sheet.cssRules;
rules.forEach((rule) => {
if (rule.type === CSSRule.KEYFRAMES_RULE) {
sheet.deleteRule(rule.name);
}
});
} catch (error) {
console.log("Error accessing stylesheet: " + error);
}
});
};

disableImageAnimations();
disableCSSAnimations();
}

// Call the function to disable features
disableFeatures();