From b3558d6fc689930e6f76bf365a0f926db42075a4 Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 5 Sep 2023 16:22:54 +1000 Subject: [PATCH] Update Compass QoL Enhancer to 1.14.0 - Automatically add the currently open learning task's ID to the URL - Derive tab IDs from their titles if they have an autogenerated one --- Compass QoL Enhancer.user.js | 27 ++++++++++++++++++++++++++- README.md | 6 ++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index 8099b3d..ba09b7f 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.13.2 +// @version 1.14.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 @@ -97,6 +97,27 @@ if (LearningTasksDetailsWidgetNew) { }; } +// Automatically add (and remove) the currently open learning task to the URL +function handleLearningTaskOpen(window) { + let search = getHashSearch(); + search.set("qol_learning_task", window.learningTask.data.id); + history.pushState("", "", `#${search.laxToString()}`); +} +function handleLearningTaskClose() { + let search = getHashSearch(); + search.delete("qol_learning_task"); + history.pushState("", "", `#${search.laxToString()}`); +} +let LearningTasksSubmissionWidget = getExtClass("Compass.widgets.LearningTasksSubmissionWidget"); +if (LearningTasksSubmissionWidget) { + let original = LearningTasksSubmissionWidget.prototype.initComponent; + LearningTasksSubmissionWidget.prototype.initComponent = function() { + original.apply(this, arguments); + handleLearningTaskOpen(this); + this.on("close", handleLearningTaskClose); + } +} + function updateInstanceButton(instanceDetails, instanceButton, offset) { // Make previous/next session buttons links let index = instanceDetails.instanceStore.indexOfId(instanceDetails.m_instanceId); @@ -222,6 +243,10 @@ function handleNewCalendarEvent(element, calendar) { function handlePanelItem(panel, panelItem, isDefault, tabToOpen) { let panelId = panelItem.itemId || panelItem.id; + // example of panel-: /Organise/Subjects/Subject.aspx + if (panelId.startsWith("panel-")) { + panelId = panelItem.title.toLowerCase().replaceAll(" ", "-"); + } let panelItemHash = getPanelItemHash(panelId, isDefault); // Automatically open tab specified in fragment diff --git a/README.md b/README.md index 21b88d6..a66539c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ A userscript that adds small but useful features for Compass. Features include: - Calendar events now show their end time without having to being hovered - Tabs are now links (you can refresh pages and the tab will automatically open. you can also ctrl+click on them) -- Files and folders in Resources is now marked clickable ([Link Hints] can now +- Files and folders in Resources are now marked clickable ([Link Hints] can now open them!) - File upload buttons now work with [Link Hints] - Links inside lesson plans now open in the parent tab by default instead of @@ -38,9 +38,11 @@ A userscript that adds small but useful features for Compass. Features include: - Ctrl-clicking an activity in a user's learning tasks tab no longer collapses everything else - Learning tasks now being links (you can ctrl-click them) +- Opening a learning task will automatically add its ID to the URL - The previous/next buttons and sessions dropdown are now links (you can now use [Link Hints] and ctrl-click to open them) -- News feed items can now be opened by simply clicking on their background +- Class and news feed items can now be opened by simply clicking on their + background - The context menu that only says "Copy" is now suppressed - The option to remember logins is unchecked by default - The dashboard tab in a user's profile no longer points you to #dsb