Manga cleaner & loader

img:click/arrow-key, back:top-left, width:top-right/w-key, load:bottom-right, remove crap

Stan na 20-11-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name     Manga cleaner & loader      
// @version     1.0.5
// @description     img:click/arrow-key, back:top-left, width:top-right/w-key, load:bottom-right, remove crap
// @namespace     https://greasyfork.org/users/3159 
// @grant     GM_getValue
// @grant     GM_setValue
// @include     http://g.e-hentai.org/s/*
// @include     http*://exhentai.org/s/*
// @include     http://*hentairules.net/galleries*/picture.php?/*
// ==/UserScript==

var loc = location.hostname.indexOf('hentairules.net') > -1 ? 1 : 2;
if (loc == 1) {
    location.href = document.getElementById('derivativeSwitchBox').children[5].href; //need to reload page for this to take effect
	var next = document.getElementById('linkNext').href;
	var o = document.getElementById('theMainImage').src;
	var t = document.getElementsByClassName('browsePath')[0].children[1].innerText;
}
else if (loc == 2) {
	var a = document.getElementsByTagName('a');
	var next = a[2].href;
	var last = a[3].href;
	var o = a[4].children[0].src;
	var t = document.title;
}
var array = [o];
var w = 0;
var i = 0;
var y = 0;
var gi;
document.head.innerHTML = '<title>' + t + '</title><style>html{height:100%}body{height:100%;margin:0}img{width:100%;max-width:100%;margin-left:auto;margin-right:auto;display:block}div{width:100px;height:100px;position:fixed}div:hover{background:rgba(0,0,0,.5)}</style>';
document.body.innerHTML = '';
img = new Image();
img.src = o;
document.body.appendChild(img);

load = document.createElement("div");
load.style.cssText = "right:0;bottom:0";
load.onclick = function () {
	y = 1;
	load.style.display = "none";
	width.style.position = back.style.position = "absolute";
	if (array[1]) {
		aimg = new Image();
		aimg.src = array[1];
		document.body.appendChild(aimg);
	}
};

back = document.createElement("div");
back.style.cssText = "top:0;left:0";
back.onclick = function () {
	if (i > 0) {
		img.src = array[--i];
	}
};

sstyle = document.createElement("style");
document.head.appendChild(sstyle);

if (GM_getValue("magsave")) {
	sstyle.innerText = "img{max-height:100%;width:inherit}";
}

function cwidth() {
	if (GM_getValue("magsave")) {
		sstyle.innerText = "img{max-height:inherit;width:100%}";
		GM_setValue("magsave", 0);
	} else {
		sstyle.innerText = "img{max-height:100%;width:inherit}";
		GM_setValue("magsave", 1);
	}
}

width = document.createElement("div");
width.style.cssText = "top:0;right:0";
width.onclick = function () {
	cwidth();
};

down = document.createElement("div");
	down.style.cssText = "bottom:0;left:0";
	down.onclick = function () {
		var images = document.getElementsByTagName("img");
		var urls = '';
		for (i = 0; i < images.length; i++) {
			urls += images[i].src;
			urls += "<br />";
		}
		urls += "copy links<br />in terminal use nano to create a file called urls<br />run the command:<br />mkdir a && cd a && xargs -n 1 curl -O < ../urls && echo 'done'";
		document.body.innerHTML = urls;
	};

document.body.appendChild(back);
document.body.appendChild(width);
document.body.appendChild(load);
document.body.appendChild(down);

var gi;
function current() {
	gi = document.getElementsByTagName('img');
	for (var a = 0; a < gi.length; a++) {
		if (window.pageYOffset + window.innerHeight >= gi[a].offsetTop) {
			o = a;
		}
	}
	return o;
}

function cnimage(i) {
	if (!gi[i] && array[i]) {
		bimg = new Image();
		bimg.src = array[i];
		document.body.appendChild(bimg);
	}
}

window.onscroll = function () {
	if (y) {
		var x = current();
		cnimage(x + 1);
		cnimage(x + 2);
		cnimage(x + 3);
		cnimage(x + 4);
	}
};

function parray() {
	r = document.implementation.createHTMLDocument("temp");
	x = new XMLHttpRequest();
	x.onreadystatechange = function () {
		if (x.readyState == 4 && x.status == 200) {
			var a = x.responseText;
			r.documentElement.innerHTML = a;
			if (loc == 1) {
				ti = r.getElementsByTagName('img')[0].outerHTML.split('src="')[1].split('"')[0];
				nn = r.getElementsByClassName('pwg-button-icon-right')[0].outerHTML;
				next = nn.split('href="')[1] ? nn.split('href="')[1].split('"')[0] : "";
				if (next === "") {
					w = 2;
				}
			}
			else if (loc == 2) {
				aa = r.getElementsByTagName('a');
				ti = aa[4].children[0].src;
				next = aa[2].href;
				if (next == last) {
					w++;
				}
			}
			array.push(ti);
			if (w < 2) {
				parray();
			}
		}
	};
	x.open('GET', next, true);
	x.send();
	return;
}
parray();

img.onclick = function () {
	if ((i + 1) < array.length) {
		img.src = array[++i];
	}
};

window.document.onkeydown = function () {};
document.addEventListener("keydown", function (e) {
	switch (e.which) {
	case 39:
		if ((i + 1) < array.length) {
			img.src = array[++i];
		}
		break;
	case 37:
		if (i > 0) {
			img.src = array[--i];
		}
		break;
	case 87:
		cwidth();
		break;
	}
});

timg1 = new Image();
timg2 = new Image();
timg3 = new Image();
timg4 = new Image();
timg5 = new Image();
timg6 = new Image();
timg7 = new Image();
timg8 = new Image();

img.onload = function () {
	window.scrollTo(0, 0);
	array[i + 1] ? timg1.src = array[i + 1] : null;
	array[i + 2] ? timg2.src = array[i + 2] : null;
	array[i + 3] ? timg3.src = array[i + 3] : null;
	array[i + 4] ? timg4.src = array[i + 4] : null;
	array[i - 1] ? timg5.src = array[i - 1] : null;
	array[i - 2] ? timg6.src = array[i - 2] : null;
	array[i - 3] ? timg7.src = array[i - 3] : null;
	array[i - 4] ? timg8.src = array[i - 4] : null;
};