Firefox Speed Optimizer

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

目前為 2024-12-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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!");
})();