e(x)hentai image resizer

resizes images to fit the height of your current device

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         e(x)hentai image resizer
// @namespace    https://greasyfork.org/users/780477
// @version      0.3
// @description  resizes images to fit the height of your current device
// @match        *://e-hentai.org/s/*
// @match        *://exhentai.org/s/*
// @grant        none
// ==/UserScript==

function change_css(){
    const img = document.getElementById('img')
    img.style.width = ''
    img.style.height = '90vh'
}

(function() {
    'use strict';

    // credits https://stackoverflow.com/a/46428962
    var oldHref = document.location.href

    var
    bodyList = document.querySelector("body")

    ,observer = new MutationObserver(function(mutations) {

        mutations.forEach(function(mutation) {

            if (oldHref != document.location.href) {

                oldHref = document.location.href;

                change_css()

            }

        });

    });

    var config = {
        childList: true,
        subtree: true
    };

    observer.observe(bodyList, config);


    change_css()


})();