From 148f9eb43d4a32adcb7839312e6fceb1d7db027d Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 7 Nov 2023 22:16:17 +1100 Subject: [PATCH] Update Compass QoL Enhancer to 1.24.0 - Treat message boxes as windows - Prevent a network request from coming out when viewing a node's permissions to prevent arousing suspicion and to make it a tiny bit faster - Fix making the "View Permission for " window clearer if the node's name is empty - Prevent clicking "Loading Class Items..." from reloading the current page - Preload subjects and classes when the page loads --- Compass QoL Enhancer.user.js | 50 ++++++++++++++++++++++++++++++++++-- README.md | 3 +++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index f0d1278..7301e8b 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.23.0 +// @version 1.24.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 @@ -85,6 +85,24 @@ if (Window) { this.on("close", handleWindowClose); }; } +// example of message boxes: remove device on /Configure/LoginAndSecurity.aspx +// for some reason, listening on Ext.window.MessageBox does nothing +let Msg = unsafeWindow.Ext ? unsafeWindow.Ext.Msg : null; +if (Msg) { + let original = Msg.show; + Msg.show = function(options) { + let originalFn = options.fn; + + options.fn = function() { + handleWindowClose(); + if (originalFn) { + originalFn.apply(this, arguments); + } + }; + handleWindowShow(); + original.apply(this, arguments); + }; +} if (productNavBar) { productNavBar.style.zIndex = 20000; @@ -325,6 +343,17 @@ if (WikiBrowserPanel) { } } }; + + let originalUpdateNodePermissions = WikiBrowserPanel.prototype.updateNodePermissions; + WikiBrowserPanel.prototype.updateNodePermissions = function() { + // prevent a network request from coming out to prevent arousing suspicion and to speed up things + let originalPostWithCallback = unsafeWindow.Compass.postWithCallback; + unsafeWindow.Compass.postWithCallback = function(url, data, callback) { + callback({d: false}); + }; + originalUpdateNodePermissions.apply(this, arguments); + unsafeWindow.Compass.postWithCallback = originalPostWithCallback; + }; } @@ -549,7 +578,7 @@ function handleNewNode(node, observer) { handleLearningTasksTable(node); } else if (node.classList.contains("x-grid-view") && unsafeWindow.Ext.getCmp(node.id).up("#submissionsPanel")) { handleLearningTaskSubmissionTable(node); - } else if (node.classList.contains("x-window") && node.querySelector(".x-window-header-text").innerText.startsWith("View Permissions for ")) { + } else if (node.classList.contains("x-window") && node.querySelector(".x-window-header-text").textContent.startsWith("View Permissions for ")) { handlePermissionsWindow(node); } @@ -662,6 +691,23 @@ for (let element of document.querySelectorAll("#productNavBar a[target='_blank'] element.removeAttribute("target"); } +// Prevent clicking "Loading Class Items..." from reloading the current page +let loadingClassItems = document.querySelector(".toolbar-classes-loading"); +if (loadingClassItems) { + loadingClassItems.addEventListener("click", function(event) { + event.preventDefault(); + }); +} + +// Preload subjects and classes when the page loads +let teachingAndLearning = document.querySelector(".toolbar-clickable-teaching-and-learning"); +if (teachingAndLearning) { + new MutationObserver(function(mutations, observer) { + observer.disconnect(); + teachingAndLearning.dispatchEvent(new MouseEvent("mouseover")); + }).observe(teachingAndLearning, {attributes: true}); +} + // unsafeWindow.CKEDITOR may not be set if you're on the login page, for example if (unsafeWindow.CKEDITOR) { // Suppress that annoying barebones context menu that only has Copy diff --git a/README.md b/README.md index 967a6ae..ca9c8a2 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,9 @@ A userscript that adds small but useful features for Compass. Features are: - Reopening panel tabs and learning tasks when the URL changes - The main navigation bar is no longer hidden behind masks that don't span the entire viewport +- Clicking on "Loading Class Items..." does nothing now instead of reloading + the current page +- Preload subjects and classes when the page loads - 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