Emp: Image Full Resolution + Stretch

Image Full Resolution + Stretch

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Emp: Image Full Resolution + Stretch
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Image Full Resolution + Stretch
// @author       bighype
// @include      /^https:\/\/www\.empornium\.(me|sx|is)\/torrents\.php\?id=\d+/
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // ==========================================
    // 1. CONFIGURE YOUR BLACKLIST HERE
    // ==========================================
    // Add filenames, domains, or folder paths you want to ignore.
    const imageBlacklist =[
        'resolution.png',
        'transdescription.png',
        'transinfo.png',
        'transscreens.png',
        'description.png',
        'info.png',
        'screens.png',
        // '/smilies/',      // Example: Ignore all images in a 'smilies' directory
        // 'icon_user.gif'   // Example: Ignore specific icon names
    ];

    const MAX_ICON_WIDTH = 60; // Images narrower than 150px will also be ignored (Set to 0 to disable)

    // Stretch images and containers inside posts
    const style = document.createElement('style');
    style.textContent = `
        /* Added :not(.no-stretch) to explicitly ignore blacklisted images */
        .body img.bbcode:not(.icon):not(.no-stretch) {
            width: 100% !important;
            height: auto !important;
            max-width: none !important;
            max-height: none !important;
        }

        /* Stretch tables and bbcode divs */
        .main_column table,
        .main_column div.bbcode {
            width: 100% !important;
            max-width: none !important;
        }
    `;
    document.head.appendChild(style);

    function applyBlacklist() {
        document.querySelectorAll('img.bbcode').forEach(img => {
            // Method A: Check against the text Blacklist
            const isBlacklisted = imageBlacklist.some(keyword => img.src.includes(keyword));

            if (isBlacklisted) {
                img.classList.add('no-stretch');
                return; // Stop checking this specific image
            }

            // Method B: Auto-detect small images based on native resolution
            if (MAX_ICON_WIDTH > 0) {
                // If the image is already loaded from cache
                if (img.complete) {
                    if (img.naturalWidth > 0 && img.naturalWidth < MAX_ICON_WIDTH) {
                        img.classList.add('no-stretch');
                    }
                } else {
                    // Wait for the image to load to check its size
                    img.addEventListener('load', function() {
                        if (this.naturalWidth < MAX_ICON_WIDTH) {
                            this.classList.add('no-stretch');
                        }
                    });
                }
            }
        });
    }

    function fixLayoutContainers() {
        document.querySelectorAll('.main_column table, .main_column div.bbcode')
            .forEach(el => {
                el.removeAttribute('width');

                if (el.style.width) {
                    el.style.width = '100%';
                }
            });
    }

    function upgradeImages() {
        document.querySelectorAll('img[src*="hamsterimg.net"]').forEach(img => {
            let src = img.src;

            let full = src
                .replace('.md.jpg', '.jpg')
                .replace('.th.jpg', '.jpg')
                .replace('.md.jpeg', '.jpeg')
                .replace('.th.jpeg', '.jpeg')
                .replace('.md.png', '.png')
                .replace('.th.png', '.png');

            if (full !== src) {
                img.src = full;
            }
        });
    }

    upgradeImages();
    applyBlacklist(); // Execute the blacklist checks
    fixLayoutContainers();
})();