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 <body> element
This commit is contained in:
blankie 2023-11-04 14:15:08 +11:00
parent 324d06fc74
commit a44f32d37a
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 46 additions and 6 deletions

View File

@ -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-<id>: /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")) {

View File

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