Firefox Speed Optimizer

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

// ==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!");
})();