Firefox Speed Optimizer

Optimizes web pages for faster loading by disabling animations, blocking ads, and optimizing images

当前为 2024-12-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Firefox Speed Optimizer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Optimizes web pages for faster loading by disabling animations, blocking ads, and optimizing images
// @author       Your Name
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Disable animations to reduce rendering time
    document.documentElement.style.setProperty('animation', 'none', 'important');
    document.documentElement.style.setProperty('transition', 'none', 'important');

    // Block unnecessary images that could slow down page load
    let images = document.querySelectorAll('img');
    images.forEach(img => {
        if (img.src && img.src.startsWith('data:image')) {
            img.src = ''; // Remove base64 images
        }
    });

    // Disable background images to speed up rendering
    document.documentElement.style.setProperty('background-image', 'none', 'important');

    // Disable web fonts (can be a heavy resource)
    let style = document.createElement('style');
    style.innerHTML = `
        @font-face { font-family: 'FontAwesome'; src: local('Arial'); }
        * { font-family: sans-serif !important; }
    `;
    document.head.appendChild(style);

    // Disable lazy loading of images (if applicable) for immediate content rendering
    let lazyImages = document.querySelectorAll('img[loading="lazy"]');
    lazyImages.forEach(img => {
        img.setAttribute('loading', 'eager');
    });

    // Disable any unnecessary third-party scripts (useful for speeding up non-essential pages)
    let scripts = document.querySelectorAll('script[src]');
    scripts.forEach(script => {
        let url = script.src.toLowerCase();
        if (url.includes('ads') || url.includes('tracking')) {
            script.remove();
        }
    });

    // Enable or set a fast refresh rate for images (optional)
    let fastRefresh = document.querySelectorAll('img');
    fastRefresh.forEach(img => {
        img.setAttribute('decoding', 'sync');
    });

    console.log("Page optimization complete!");
})();