ExHentai - Preload next page

Loosely inspired by "Handy ExHentai" script. Now loads more pages by nesting iFrames.

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 or Violentmonkey 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		ExHentai - Preload next page
// @version	1.1
// @namespace	exhentai-preload-page
// @author	BlindJoker
// @homepage	https://github.com/BlindJoker
// @description	Loosely inspired by "Handy ExHentai" script. Now loads more pages by nesting iFrames.
// @match		http://exhentai.org/s/*
// @match		http://g.e-hentai.org/s/*
// @run-at		document-end
// @grant		none
// ==/UserScript==
/*
* Let the user scripts or content scripts running in an annoymous function.
*/
(function (window) {
	"use strict";

	var pnext = document.getElementById("next").href;

	// Prevents possible infinite loadings
	if(window.self !== window.top && window.location.href == pnext) {
		console.log("finished loading everything");
		return;
	}

	var nframe = document.createElement("iframe");
	nframe.src = pnext;
	nframe.id = "nframe";
	nframe.style.width = "1px";
	nframe.style.height = "1px";
	nframe.style.border = "none";

	document.getElementById("img").addEventListener('load', function() {
		document.body.appendChild(nframe);
	});

	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() {" +
			"		document.getElementById('nframe').src = document.getElementById('next').href;" +
			"	});" +
			"}";

	document.head.appendChild(script);
}) (window);