Skip to content

Commit

Permalink
Clicks outside the favorite menu will now close it
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Aug 28, 2024
1 parent e6682c1 commit 53cfcad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion 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.1
// @version 1.3.2
// @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 @@ -43,6 +43,7 @@

// Create the menu element
const menu = document.createElement('div');
menu.id = 'location-favo-menu';
menu.style.position = 'fixed';
menu.style.top = '50%';
menu.style.left = '50%';
Expand Down Expand Up @@ -179,4 +180,12 @@
}
}
});

// Add event listener to close the menu when clicking outside of it
document.addEventListener('click', function(event) {
const menu = document.querySelector('#location-favo-menu'); // Replace with your actual menu selector
if (menu && !menu.contains(event.target)) {
hideMenu();
}
});
})();

0 comments on commit 53cfcad

Please sign in to comment.