Last active
June 6, 2026 05:26
-
-
Save tkoenig89/d9c2eaa9f37538abc2163ecd4e6fb28c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Azure Portal Hotkeys (Fix for german keyboards) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Enables hotkeys for the azure portal which are broken for german keyboards | |
| // @author Tobias König | |
| // @match https://portal.azure.com/* | |
| // @icon https://www.google.com/s2/favicons?domain=azure.com | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| let commandKey = null; | |
| let searchBarFn = () => focusSearchBar(); | |
| const shortcutMap = { | |
| G: { | |
| '/': searchBarFn, | |
| }, | |
| g: { | |
| '/': searchBarFn, | |
| n: () => openLink('#create/hub'), | |
| a: () => openLink('#blade/HubsExtension/BrowseAll'), | |
| r: () => openLink('#blade/HubsExtension/BrowseResourceGroups'), | |
| }, | |
| }; | |
| /** | |
| * | |
| * @param e {KeyboardEvent} | |
| */ | |
| function doc_keyUp(e) { | |
| if (e.target.tagName.toLowerCase() == 'input') { | |
| return; | |
| } | |
| if (!commandKey) { | |
| tryToSetCommandKey(e); | |
| } else { | |
| const command = shortcutMap[commandKey]; | |
| const action = command[e.key]; | |
| if (action) { | |
| action(); | |
| resetCommandKey(); | |
| } else { | |
| tryToSetCommandKey(e.key); | |
| } | |
| } | |
| } | |
| function openLink(url) { | |
| location.href = url; | |
| } | |
| function focusSearchBar() { | |
| var search = document.querySelector('.azc-input._wv_locator__wv_elemref_1'); | |
| search.focus(); | |
| } | |
| function resetCommandKey() { | |
| commandKey = null; | |
| } | |
| function tryToSetCommandKey(e) { | |
| const topLevel = shortcutMap[e.key]; | |
| if (topLevel) { | |
| commandKey = e.key; | |
| } else { | |
| resetCommandKey(); | |
| } | |
| } | |
| document.addEventListener('keyup', doc_keyUp, false); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment