Manganelo Helper

Allows you to use the left and right arrow keys to navigate chapters at Manganelo, and removes space between images.

目前为 2020-10-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         Manganelo Helper
// @namespace    GF-Fear3d
// @version      0.1
// @description  Allows you to use the left and right arrow keys to navigate chapters at Manganelo, and removes space between images.
// @author       Fear3d
// @match        https://manganelo.com/chapter/*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// ==/UserScript==

(function() {
 	'use strict';

 	var nextUrl = "";
 	var prevUrl = "";

 	// List of titles that we want to have no image margines - Add more as you please
 	var titleList = [
 		"A Returner's Magic Should Be Special",
 		"Solo Leveling",
 		"I Am The Sorcerer King",
 		"I, Who Blocked The Demon King's Ultimate Attack, Ended Up As The Little Hero's Nanny!",
 		"The Top Clan Leader In History",
 		"The Ghostly Doctor",
 		"God Of Martial Arts",
 		"Spirit Sword Sovereign",
 		"Tang Yin Zai Yi Jie",
 		"The God Of High School",
 		"Tower Of God",
 		"Tomb Raider King"
 	];

 	// Find URLs for Next and Prev
 	$(document).ready(function() {
 		var nextPage, prevPage;

 		if ($("a.navi-change-chapter-btn-next.a-h").length) {
 			nextPage = $("a.navi-change-chapter-btn-next.a-h:first");
 		} 
 		else {
 			nextPage = $("div.container:nth-child(1) > div.panel-breadcrumb:nth-child(2) > a:nth-child(3)");
 		}

 		if ($("a.navi-change-chapter-btn-prev.a-h").length) {
 			prevPage = $("a.navi-change-chapter-btn-prev.a-h:first");
 		} 
 		else {
 			prevPage = $("div.container:nth-child(1) > div.panel-breadcrumb:nth-child(2) > a:nth-child(3)");
 		}

    	nextUrl = nextPage.attr("href");
    	prevUrl = prevPage.attr("href");
	});

 	// Handle arrow key events
	$(document).ready(function() {
 		document.onkeydown = function(evt) {
 			switch (evt.keyCode) {
 				case 37: // Left Arrow
 					window.location = prevUrl;
 					break;
 				case 39: // Right Arrow
 					window.location = nextUrl;
 					break;
 			}
 		};
 	});

 	// Remove margins between images on specified titles
 	$(document).ready(function() {
 		var myTitle = $("div.container:nth-child(1) > div.panel-breadcrumb:nth-child(2) > a:nth-child(3)").text();

 		if (titleList.indexOf(myTitle) == -1) {
 			return;
 		}

 		$(".container-chapter-reader img").css("margin", "0px auto 0");
 	});

})();