Update Compass QoL Enhancer to 1.20.0

- Prevent scrolling if a window is open
- Hide user's last name on learning tasks
This commit is contained in:
blankie 2023-10-23 13:44:34 +11:00
parent 52a151ae36
commit 40268aade6
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 29 additions and 1 deletions

View File

@ -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

View File

@ -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/