Emp: Image Full Resolution + Stretch

Image Full Resolution + Stretch

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Emp: Image Full Resolution + Stretch
// @namespace    http://tampermonkey.net/
// @version      1.5
// @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';

    // Stretch images and containers inside posts
    const style = document.createElement('style');
    style.textContent = `
        .body img.bbcode:not(.icon) {
            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 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();
    fixLayoutContainers();
})();