Emp: Image Full Resolution + Stretch

Image Full Resolution + Stretch

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Emp: Image Full Resolution + Stretch
// @namespace    http://tampermonkey.net/
// @version      1.19
// @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
    // ==========================================
    const imageBlacklist =[
        "25_fps_small.png",
        "Audio2.png",
        "ContactSheet.png",
        "DarkRoomVRLogo.png",
        "Date.png",
        "Details.png",
        "details11.png",
        "Disk.png",
        "Duration.png",
        "Many_Vids2-removebg-preview.png",
        "plot11.png",
        "Resolution.png",
        "screens11.png",
        "Screenshots.png",
        "transdescriptiona42c6695c0b6ff7f.png",
        "transscreens5c2af024a602b52c.png",
        "Unknown.png",
        "Up2.png",
        "Video.png",
        "VR2Normal.png",
        "VR2NormalFile.png",
        '1080p_small77cdb8aab8ac9b6f.png',
        '1440p_small.png',
        '24_fps_small.png',
        '6WeZ8Wb3.png',
        '8gznl0Wd.png',
        'cast11.jpg',
        'codec_avc.png',
        'codec_hevc.png',
        'DailyUploadTrophy.png',
        'description.png',
        'Description.png',
        'details.png',
        'DhJP_5Ad.png',
        'image-11CE_51D7BCFD.gif',
        'image-186D_51D7488B.gif',
        'image-23EC_51D7BCFD.gif',
        'image-3CB6_51D7BCFD.gif',
        'image-A37C_4F735C36.gif',
        'image-B367_51D7461D.jpg',
        'image-BAAC_51D7BCFD.gif',
        'image-C696_51D7461D.jpg',
        'info.png',
        'Info.png',
        'lrCYQL12.png',
        'mp4_small9dfd7fe55e0fad20.png',
        'onlyfans-02-logo.png',
        'other.png',
        'plot11.jpg',
        'resolution.png',
        'screens.png',
        'Screens.png',
        'screens11.jpg',
        'screenshots.png',
        'transdescription.png',
        'transinfo.png',
        'transscreens.png',
        'zciirfa1.png',
        'Plot.png',
        'Previews.png',
        'Information.png',
        'test5.png',
        'Cast.png',
        'image-E8A8_53B31227.jpg',
        'image-C08E_53B32551.jpg',
        'image-D988_53B330EC.jpg',
        'descp-comicsansms.png',
        'info-comicsansms.png',
        'details-comincsansms.png',
        'screens-comicsansms.png',
        'cb-384.png',
        'info11.jpg',
        'sup_Casting.png',
        'sup_Deets.png',
        'sup_CS.png',
        'cast11.png',
        'info11.png',
        '1080p.png',
        'H264.png',
        'mp4.png',
        '24-fps.png',
        'medium_1200px-OnlyFans_logo.svg.png',
        // '/smilies/',      // Example: Ignore all images in a 'smilies' directory
        // 'icon_user.gif'   // Example: Ignore specific icon names
    ];

    const MAX_ICON_WIDTH = 60;

    const supportedImageHosts = [
        "hamsterimg.net",
        "fapping.empornium.sx",
    ];

    const thumbnailReplacements = [
        { from: ".md.jpg", to: ".jpg" },
        { from: ".th.jpg", to: ".jpg" },
        { from: ".md.jpeg", to: ".jpeg" },
        { from: ".th.jpeg", to: ".jpeg" },
        { from: ".md.png", to: ".png" },
        { from: ".th.png", to: ".png" },
        { from: ".md.webp", to: ".webp" },
        { from: ".th.webp", to: ".webp" },
        { from: "thumb-", to: "image-" },
    ];

    const style = document.createElement('style');
    style.textContent = `
        .body img.bbcode:not(.icon):not(.no-stretch) {
            width: 100% !important;
            height: auto !important;
            max-width: none !important;
            max-height: none !important;
        }

        .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 => {
            const isBlacklisted = imageBlacklist.some(keyword => img.src.includes(keyword));

            if (isBlacklisted) {
                img.classList.add('no-stretch');
                return;
            }

            if (MAX_ICON_WIDTH > 0) {
                if (img.complete) {
                    if (img.naturalWidth > 0 && img.naturalWidth < MAX_ICON_WIDTH) {
                        img.classList.add('no-stretch');
                    }
                } else {
                    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 isSupportedHost(url) {
        try {
            const hostname = new URL(url).hostname;
            return supportedImageHosts.some(domain => hostname.includes(domain));
        } catch {
            return false;
        }
    }

    function upgradeImages() {
        document.querySelectorAll('img').forEach(img => {
            if (!isSupportedHost(img.src)) return;

            let src = img.src;
            let full = src;

            thumbnailReplacements.forEach(rule => {
                if (full.includes(rule.from)) {
                    full = full.replace(rule.from, rule.to);
                }
            });

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

    upgradeImages();
    applyBlacklist();
    fixLayoutContainers();
})();