AWSW better navigation

Make img fullsize and add navigations with ← → keys

目前为 2024-09-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         AWSW better navigation
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Make img fullsize and add navigations with ← → keys
// @author       Титан
// @match        https://angelswithscalywings.com/comics/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=angelswithscalywings.com
// @require      https://cdn.jsdelivr.net/npm/[email protected]/src/arrive.min.js
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
	'use strict';
	var styles = `
    img {
    width: unset;
    }
`
	var styleSheet = document.createElement("style")
	styleSheet.textContent = styles
	document.head.appendChild(styleSheet)
	console.log("AWSW better navigation loded");

	// Проверяем, загружена ли библиотека arrive
	if (typeof document.arrive === 'function') {
		console.log('arrive is loaded');
	} else {
		console.log('arrive is not loaded');
	}


	document.arrive("div.comics-navigation", {onceOnly: false, existing: true},function(newElem) {
		console.log("comics-navigation arrived");
		addNavHotkeys(newElem);
	}, );

	function addNavHotkeys(comicsNavigation){
		console.log("injecting hotkeys of navigation");

		let comicNavChilds = comicsNavigation.children;
		//: buttons in comicsNavigation
		let firstPage = comicNavChilds[0];
		let prevPage = comicNavChilds[1];
		let nextPage = comicNavChilds[2];
		let lastPage = comicNavChilds[3];

		document.addEventListener('keydown', function(event) {
			if (event.key === 'ArrowRight') {
				//: if alt is holding
				if (event.altKey) {
					lastPage.click();
				}
				else {
					nextPage.click();
				}
			}

			if (event.key === 'ArrowLeft') {
				//: if alt is holding
				if (event.altKey) {
					firstPage.click();
				}
				else {
					prevPage.click();
				}
			}
		});
	}

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址