diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index 33047fe..fad8bba 100644 --- a/Compass QoL Enhancer.user.js +++ b/Compass QoL Enhancer.user.js @@ -2,7 +2,7 @@ // @name Compass QoL Enhancer // @namespace blankie-scripts // @match http*://*.compass.education/* -// @version 1.18.1 +// @version 1.19.0 // @author blankie // @description A userscript that adds small but useful features for Compass, such as the ability to close windows by clicking on the background // @inject-into page @@ -503,6 +503,20 @@ document.body.addEventListener("click", function(event) { } }, {passive: true}); +// Allow submitting links by pressing Enter instead of clicking the button +document.body.addEventListener("keydown", function(event) { + if (event.key !== "Enter" || event.target.localName !== "input" || event.target.type !== "text") { + return; + } + + let window = unsafeWindow.Ext.getCmp(event.target.closest(".x-window").id); + if (!window || window.itemId !== "urlSelectionModal") { + return; + } + + window.down("#saveButton").handler(); +}, {passive: true}); + // Stop the calendar and email buttons from opening in a new tab for (let element of document.querySelectorAll("#productNavBar a[target='_blank']")) { element.removeAttribute("target"); diff --git a/README.md b/README.md index d5d0086..5dd671e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ A userscript that adds small but useful features for Compass. Features are: - Files and folders in Resources are now marked clickable ([Link Hints] can now open them!) - File upload buttons now work with [Link Hints] +- Fix submitting links by simply pressing Enter - Links inside lesson plans now open in the parent tab by default instead of creating a new tab - Links submitted to learning tasks are now actual links (they now work with @@ -55,7 +56,7 @@ A userscript that adds small but useful features for Compass. Features are: - The context menu that only says "Copy" is now suppressed - Workaround a [Link Hints bug](https://github.com/lydell/LinkHints/issues/86) that prevents it from seeing links inside lesson plans and such -- FIles and folders in Resources are now sorted alphabetically +- Files and folders in Resources are now sorted alphabetically - The option to remember logins is unchecked by default - The dashboard tab in a user's profile no longer points you to #dsh