AniDB Thumbnails Expander and Higer Resolution Loader

Replace AniDB thumbnails with high-res images and make them larger

// ==UserScript==
// @name         AniDB Thumbnails Expander and Higer Resolution Loader
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Replace AniDB thumbnails with high-res images and make them larger
// @author       Anon1337Elite
// @match        https://anidb.net/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Add CSS to make thumbnails larger
    const style = document.createElement('style');
    style.textContent = `
        .g_image.thumb {
            width: 300px !important; /* Adjust the width as needed */
            height: auto !important; /* Maintain aspect ratio */
            max-width: none !important; /* Disable maximum width */
        }
    `;
    document.head.appendChild(style);

    // Function to replace thumbnail URLs with higher resolution URLs
    function replaceThumbnails() {
        document.querySelectorAll('img').forEach(img => {
            if (img.src.includes('-thumb')) {
                img.src = img.src.replace('-thumb', '');
                img.src = img.src.replace('.jpg', '');
            }
        });
    }

    // Run the replacement function after the page has fully loaded
    window.addEventListener('load', () => {
        replaceThumbnails();
        setTimeout(replaceThumbnails, 500); // Additional initial check after 500ms
    });

    // Use MutationObserver to replace URLs in dynamically loaded content
    const observer = new MutationObserver(replaceThumbnails);
    observer.observe(document.body, { childList: true, subtree: true });

    // Periodic check to ensure all images are high-res, every 1 second
    setInterval(replaceThumbnails, 1000);
})();