From 40268aade66b4688b0ae69763cf1e561ea581da6 Mon Sep 17 00:00:00 2001 From: blankie Date: Mon, 23 Oct 2023 13:44:34 +1100 Subject: [PATCH] Update Compass QoL Enhancer to 1.20.0 - Prevent scrolling if a window is open - Hide user's last name on learning tasks --- Compass QoL Enhancer.user.js | 28 +++++++++++++++++++++++++++- README.md | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index 5c2e2e4..281ca0a 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.19.1 +// @version 1.20.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 @@ -13,6 +13,7 @@ let qolTabOpened = false; let qolLearningTaskOpened = false; +let shownWindows = 0; // needed because .toString() adds a trailing = for empty values URLSearchParams.prototype.laxToString = function() { @@ -60,6 +61,27 @@ function getPanelItemHash(panelId, isDefault) { +// Prevent scrolling if a window is open +function handleWindowShow() { + shownWindows++; + document.documentElement.style.overflow = "hidden"; +} +function handleWindowClose() { + shownWindows--; + if (shownWindows <= 0) { + document.documentElement.style.overflow = ""; + } +} +let Window = getExtClass("Ext.window.Window"); +if (Window) { + let original = Window.prototype.initComponent; + Window.prototype.initComponent = function() { + original.apply(this, arguments); + this.on("show", handleWindowShow); + this.on("close", handleWindowClose); + }; +} + // Prevent the dashboard tab in the user page being "dsh" let UserProfileNewWidget = getExtClass("Compass.widgets.UserProfileNewWidget"); if (UserProfileNewWidget) { @@ -292,8 +314,12 @@ function handleNewCalendarEvent(element, calendar) { if (calendarPanel.targetUserId !== undefined) { a.href += `?userId=${calendarPanel.targetUserId}`; } + // Link specifically to the learning task a.href += `#learningTasks&qol_learning_task=${calendarData.learningTaskId}`; + + // Hide user's last name on learning tasks + calendarData.longTitleWithoutTime = calendarData.longTitleWithoutTime.replace(/^.+?, /, ""); } // Show the finish time for applicable calendar events diff --git a/README.md b/README.md index 5dd671e..18fee21 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ A userscript that adds small but useful features for Compass. Features are: - 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 +- Pages can no longer be scrolled if a window is currently open +- The user's last name is hidden on learning tasks [Link Hints]: https://lydell.github.io/LinkHints/