Greasy Fork

Greasy Fork is available in English.

MTL Novel Arrow Key Nav

Allows you to use the left and right arrow keys to navigate chapters at mtlnovel.com, and fixes the Night Mode theme

当前为 2020-10-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         MTL Novel Arrow Key Nav
// @namespace    GF-Fear3d
// @version      1.0
// @description  Allows you to use the left and right arrow keys to navigate chapters at mtlnovel.com, and fixes the Night Mode theme
// @author       Fear3d
// @match        https://www.mtlnovel.com/*/*/
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// ==/UserScript==

(function() {
 	'use strict';

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

 	// Find URLs for Next and Prev
 	$(document).ready(function() {
		var nextPage = $("a.next:first");
    	var prevPage = $("a.prev:first");
    	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;
 			}
 		};
 	});

	// Some Costmetic fixes in this function
 	$(document).ready(function() {

 		if ($("body.nightmode-on").length) { 
 			// Changes color of donation banner in night mode and replaces ko-fi image
 			$("div.donations").css("background-color", "#1f2129");
 			$(".donations > p:nth-child(2) > a:nth-child(1) > amp-img:nth-child(1)").attr("src", "https://i.imgur.com/3rT5sKF.png");
 			$(".donations > p:nth-child(2) > a:nth-child(1) > amp-img:nth-child(1) > amp-img:nth-child(1)").attr("src", 
 				"https://i.imgur.com/3rT5sKF.png");
 			$("img.i-amphtml-fill-content:nth-child(2)").attr("src", "https://i.imgur.com/3rT5sKF.png");

 			// Darken the settings button
	 		$("button#settings").css("background", "#2f3139 url(https://gist.githubusercontent.com/Fear3d/ad0120e349ceba72f78f5827d773c412/raw/" + 
	 			"dea64d2251436d2af8e715952fadbbd711ab688c/cog-outline.svg) 4px 5px no-repeat");
	 		$("button#settings").css({"color": "#7a9999", "border": "1px solid #2f3139"});
	 		$("button#settings").hover(function() {
	 			$(this).css("background", "#337ab7 url(https://gist.githubusercontent.com/Fear3d/90e0bdf84768b621d824b96cce0d37b1/raw/cf0597ac1" + 
	 				"f5b4b841cefddecaff8724bc6348bc7/cog-outline-hover.svg) 4px 5px no-repeat");
	 			$(this).css({"color": "white", "border": "1px solid #337ab7"});
	 			}, function() {
	 			$(this).css("background", "#2f3139 url(https://gist.githubusercontent.com/Fear3d/ad0120e349ceba72f78f5827d773c412/raw/" + 
	 				"dea64d2251436d2af8e715952fadbbd711ab688c/cog-outline.svg) 4px 5px no-repeat");
	 			$(this).css({"color": "#7a9999", "border": "1px solid #2f3139"});
	 		});
 		}

 		// Hides blank space in middle of chapter (probably caused by one of MTLNovel's ad scripts that my adblocker is blocking)
 		$("#mgid-under").hide();
 	});

})();