Allows L/R arrow key navigation between chapters & reize chapter images using / key.
当前为
// ==UserScript==
// @name MangaNelo Scripts (Next/Prev Chapter & Image Resize)
// @namespace ew0345
// @match *://manganelo.com/chapter/*/*
// @grant none
// @version 1.2
// @author ew0345, Qther
// @description Allows L/R arrow key navigation between chapters & reize chapter images using / key.
// ==/UserScript==
var img = ['.container-chapter-reader img'];
var wper = 100;
function resize() {
var inp = prompt('Image Width / %\n\'autoh\' to fit images to page height,\n\'autow\' to fit images to page width.');
wper = inp.valueOf().toLowerCase();
console.log(wper);
if (wper === "autow" || wper === "w" || wper === "fitw") {
var pageWidth = $(document).width();
console.log(pageWidth);
for (var i = 0; i < document.querySelectorAll(img).length; i++) {
document.querySelectorAll(img)[i].style.width = pageWidth / document.querySelectorAll(img)[i].width * 100 + '%';
}
} else if (wper === "autoh" || wper === "h" || wper === "fith" || wper === "4koma") {
var pageWidth = $(document).width();
var pageHeight = $(window).height();
console.log(pageHeight);
for (var i = 0; i < document.querySelectorAll(img).length; i++) {
document.querySelectorAll(img)[i].style.width = pageWidth / document.querySelectorAll(img)[i].width * 100 + '%';
document.querySelectorAll(img)[i].style.width = pageHeight / document.querySelectorAll(img)[i].height * 100 + '%';
}
} else {
for (var i = 0; i < document.querySelectorAll(img).length; i++) {
document.querySelectorAll(img)[i].style.width = wper + '%';
}
}
}
window.onkeydown = function(e) {
switch (e.key) {
case "ArrowLeft":
$('a:contains("PREV CHAPTER")').length > 0 ? document.location = $('a:contains("PREV CHAPTER")').attr('href') : console.error('Already on last chapter.');
break;
case "ArrowRight":
$('a:contains("NEXT CHAPTER")').length > 0 ? document.location = $('a:contains("NEXT CHAPTER")').attr('href') : console.error('Already on first chapter.');
break;
case "/":
resize();
break;
default:
break;
}
}