Improved EH Reader

Inspired by Handy ExHentai and ExHentai - Preload next page. Simplifies the reader layout and preloads the next image. Preloading improved to not use an iframe.

目前為 2022-02-11 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Improved EH Reader
// @namespace     karoo
// @version       2022.02.11
// @description   Inspired by Handy ExHentai and ExHentai - Preload next page. Simplifies the reader layout and preloads the next image. Preloading improved to not use an iframe.
// @match         *://e-hentai.org/s/*
// @match         *://exhentai.org/s/*
// @run-at        document-end
// @grant         unsafeWindow
// @noframes
// ==/UserScript==

function id(id) {return document.getElementById(id);}
if (typeof unsafeWindow === "undefined"){unsafeWindow = window;}
if (window.top !== window.self) {return;}

// hide top panel and front page link
id("i1").firstElementChild.style.display = "none";
id("i2").style.display = "none";
document.getElementsByClassName("dp")[0].style.display = "none";

// hide frame and fix margins
id("i1").style.background = "none";
id("i1").style.border = "none";
id("i1").style.margin = "0px auto 0px";
id("i7").style.margin = "-5px auto 0px";

// preload next image without iframe
var preload = new Image();
function preloadNext() {
    if (history.length <= 1 || id("next").href == window.location.href) {return;} // don't preload if on last page or new tab
    var lookahead = new XMLHttpRequest();
    lookahead.open("GET", id("next").href, false);
    lookahead.send();
    var doc = document.implementation.createHTMLDocument('lookahead');
    doc.documentElement.innerHTML = lookahead.responseText;
    var nextImage = doc.getElementById("img").src;
    preload.src = nextImage;
}
unsafeWindow.preloadNext = preloadNext;

// preload next image after navigation
var script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML =
    "var uweo = update_window_extents;" +
    "update_window_extents = function() {" +
    " 	uweo();" +
    "	document.getElementById('img').addEventListener('load', function() {" +
    "       preloadNext()" +
    "	});" +
    "}";
document.head.appendChild(script);