From a44f32d37acbd43ccb182829397cffffb81835d8 Mon Sep 17 00:00:00 2001 From: blankie Date: Sat, 4 Nov 2023 14:15:08 +1100 Subject: [PATCH] Update Compass QoL Enhancer to 1.22.0 - Reveal extra controls on Resources/wikis - Fix weird bugs with School Documentation - Fix panelItem.title is undefined bugs on pages like School Documentation - Ignore masks not directly on the element --- Compass QoL Enhancer.user.js | 50 +++++++++++++++++++++++++++++++----- README.md | 2 ++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index 15fd246..a58f7ee 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.21.0 +// @version 1.22.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 @@ -286,11 +286,36 @@ if (WikiBrowserPanel) { let originalRenderLayout = WikiBrowserPanel.prototype.renderLayout; WikiBrowserPanel.prototype.renderLayout = function() { + // Reveal filter and refresh toolbars + let readOnly = this.readOnly; + this.readOnly = false; originalRenderLayout.apply(this, arguments); - try { + this.readOnly = readOnly; + + // hide tools button and context menu since it is useless to us + this.treePanel.down("#toolButton").hidden = true; + this.treePanel.events.itemcontextmenu = true; + + // check if root node exists, otherwise pages like /Communicate/SchoolDocumentation.aspx will die + if (this.treePanel.getRootNode()) { this.treePanel.store.sort({sorterFn: wikiNodeSort}); - } catch (e) { - // /Communicate/SchoolDocumentation.aspx dies for some reason + } + }; + + let originalSelectedNodeChanged = WikiBrowserPanel.prototype.selectedNodeChanged; + WikiBrowserPanel.prototype.selectedNodeChanged = function() { + // Reveal "View Permissions", "Visible to", and "Created by" + let readOnly = this.readOnly; + this.readOnly = false; + originalSelectedNodeChanged.apply(this, arguments); + this.readOnly = readOnly; + + // hide things we can't touch + let toolbar = this.nodeViewerPanel.down("toolbar"); + for (let item of toolbar.items.items) { + if (item.disabled) { + toolbar.remove(item); + } } }; } @@ -366,7 +391,8 @@ function handlePanel(panel) { function handlePanelItem(panel, panelItem, isDefault, tabToOpen) { let panelId = panelItem.itemId || panelItem.id; // example of panel-: /Organise/Subjects/Subject.aspx - if (panelId.startsWith("panel-")) { + // example of panelItem.title being undefined: /Communicate/SchoolDocumentation.aspx + if (panelId.startsWith("panel-") && panelItem.title) { panelId = panelItem.title.toLowerCase().replaceAll(" ", "-"); } let panelItemHash = getPanelItemHash(panelId, isDefault); @@ -456,6 +482,13 @@ 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 handleCKEditor(instance) { instance.on("contentDom", function() { let editable = instance.editable(); @@ -510,6 +543,11 @@ 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); + } } if (node.classList.contains("cke")) { @@ -535,7 +573,7 @@ let observer = new MutationObserver(function(mutations, observer) { observer.observe(document.body, {childList: true, subtree: true}); document.body.addEventListener("click", function(event) { - if (event.target.classList.contains("x-mask")) { + if (event.target.classList.contains("x-mask") && event.target.parentElement.localName === "body") { // Add the ability to close windows by clicking on the background let maskZIndex = BigInt(event.target.style.zIndex); for (let maskMsg of document.querySelectorAll(".x-mask-msg")) { diff --git a/README.md b/README.md index dda5c33..bf13295 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ A userscript that adds small but useful features for Compass. Features are: open. you can also ctrl+click on them) - Files and folders in Resources are now marked clickable ([Link Hints] can now open them!) +- Revealing extra features in Resources (such as filter, created by, and + permission information) - File upload buttons now work with [Link Hints] - Fix submitting links by simply pressing Enter - Links inside lesson plans now open in the parent tab by default instead of