[T] AWSW better navigation

Make img fullsize and add navigations with ← → keys

Fra og med 10.09.2024. Se den nyeste version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         [T] AWSW better navigation
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @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
// @grant        none
// @license      MIT
// ==/UserScript==

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

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

	function addNavHotkeys(comicsNavigation){
		console.log("[AWSW BN] 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();
				}
			}
		});
	}

})();