Update Compass QoL Enhancer to 1.23.0

- Put the nav bar over or behind masks when necessary
- Fix going to the first tab on hash changes on pages such as
/Organise/Subjects/Subject.aspx
This commit is contained in:
blankie 2023-11-04 14:42:10 +11:00
parent a44f32d37a
commit a0f8954ba4
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 17 additions and 12 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer
// @namespace blankie-scripts
// @match http*://*.compass.education/*
// @version 1.22.0
// @version 1.23.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
@ -15,6 +15,7 @@ let qolTabOpened = false;
let qolLearningTaskOpened = false;
let modifyUrlHash = true;
let shownWindows = 0;
let productNavBar = document.querySelector("#productNavBar");
// needed because .toString() adds a trailing = for empty values
URLSearchParams.prototype.laxToString = function() {
@ -62,15 +63,17 @@ function getPanelItemHash(panelId, isDefault) {
// Prevent scrolling if a window is open
// Prevent scrolling if a window is open, and put the nav bar over or behind masks when necessary
function handleWindowShow() {
shownWindows++;
document.documentElement.style.overflow = "hidden";
productNavBar.style.zIndex = "";
}
function handleWindowClose() {
shownWindows--;
if (shownWindows <= 0) {
document.documentElement.style.overflow = "";
productNavBar.style.zIndex = 20000;
}
}
let Window = getExtClass("Ext.window.Window");
@ -83,6 +86,10 @@ if (Window) {
};
}
if (productNavBar) {
productNavBar.style.zIndex = 20000;
}
// Prevent the dashboard tab in the user page being "dsh"
let UserProfileNewWidget = getExtClass("Compass.widgets.UserProfileNewWidget");
if (UserProfileNewWidget) {
@ -483,10 +490,9 @@ function handleLearningTaskSubmissionTable(element) {
}
// Make permissions grid more visible
function handlePermissionsWindow(window) {
let grid = window.down("grid");
grid.el.dom.querySelector(".x-mask").remove();
grid.body.dom.style.pointerEvents = "none";
function handlePermissionsWindow(node) {
node.querySelector(".x-mask").remove();
node.querySelector(".x-grid-body").style.pointerEvents = "none";
}
function handleCKEditor(instance) {
@ -543,11 +549,8 @@ 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")) {
let window = unsafeWindow.Ext.getCmp(node.id);
if (window.title.startsWith("View Permissions for ")) {
handlePermissionsWindow(window);
}
} else if (node.classList.contains("x-window") && node.querySelector(".x-window-header-text").innerText.startsWith("View Permissions for ")) {
handlePermissionsWindow(node);
}
if (node.classList.contains("cke")) {
@ -634,7 +637,7 @@ window.addEventListener("hashchange", function(event) {
panel = unsafeWindow.Ext.getCmp(panel.id);
if (isActivityPage && hashSearch.has("openLearningTaskTab")) {
panel.setActiveTab(getLearningTaskTab(panel));
} else if (isActivityPage && hashSearch.size === 1) {
} else if (hashSearch.size === 0 || (isActivityPage && hashSearch.size === 1)) {
event.stopImmediatePropagation();
panel.setActiveTab(panel.items.items[0]);
} else {

View File

@ -60,6 +60,8 @@ A userscript that adds small but useful features for Compass. Features are:
that prevents it from seeing links inside lesson plans and such
- Files and folders in Resources are now sorted alphabetically
- 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
- 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