Skip to content

Commit

Permalink
Page scrolling with up/down is temporary disabled while the menu is v…
Browse files Browse the repository at this point in the history
…isible
  • Loading branch information
on committed Aug 28, 2024
1 parent 5b1a921 commit 0368cdd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions yr.user.js
Original file line number Diff line number Diff line change
@@ -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/*
Expand Down Expand Up @@ -71,7 +71,6 @@

menu.innerHTML = '<ul>' + locations.map((location, index) => `
<li data-id="${location.id}" data-index="${index}">
<span class="weather-location-list-item__star--filled"></span>
${location.name}
</li>`).join('') + '</ul>';
menu.style.display = 'block';
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 0368cdd

Please sign in to comment.