From 0368cddb2a70cdee15f9e46e16ce30a8b405627a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Andreas=20Nilsen?= Date: Wed, 28 Aug 2024 12:26:21 +0200 Subject: [PATCH] Page scrolling with up/down is temporary disabled while the menu is visible --- yr.user.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yr.user.js b/yr.user.js index e7c7b10..cb2c0d3 100644 --- a/yr.user.js +++ b/yr.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name YR.no - Hotkeys // @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/ -// @version 1.3.0 +// @version 1.3.1 // @description Navigate the yr.no navbar using `Ctrl` + `←`/`→`. Navigate to 21-day forecast, radar map or daily table view using `Alt` + `L`, `Alt` + `R` or `Alt` + `V`. Show a menu to navigate through favorite locations with `Ctrl` + `Shift` + `F`. // @author Øyvind Nilsen (on@ntnu.no) // @match https://www.yr.no/* @@ -71,7 +71,6 @@ menu.innerHTML = ''; menu.style.display = 'block'; @@ -108,9 +107,11 @@ if (event.key === 'Escape') { hideMenu(); } else if (event.key === 'ArrowUp') { + event.preventDefault(); // Prevent default scrolling behavior selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : items.length - 1; highlightSelected(); } else if (event.key === 'ArrowDown') { + event.preventDefault(); // Prevent default scrolling behavior selectedIndex = (selectedIndex < items.length - 1) ? selectedIndex + 1 : 0; highlightSelected(); } else if (event.key === 'Enter') {