Update Compass QoL Enhancer to 1.19.1

- Fix sorting resources when it's initially opened
This commit is contained in:
blankie 2023-10-13 14:49:09 +11:00
parent 6fefb06b1f
commit 570b60f927
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 13 additions and 3 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer // @name Compass QoL Enhancer
// @namespace blankie-scripts // @namespace blankie-scripts
// @match http*://*.compass.education/* // @match http*://*.compass.education/*
// @version 1.19.0 // @version 1.19.1
// @author blankie // @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 // @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 // @inject-into page
@ -242,13 +242,23 @@ function wikiNodeSort(lhs, rhs) {
} }
let WikiBrowserPanel = getExtClass("Compass.widgets.WikiBrowserPanel"); let WikiBrowserPanel = getExtClass("Compass.widgets.WikiBrowserPanel");
if (WikiBrowserPanel) { if (WikiBrowserPanel) {
let original = WikiBrowserPanel.prototype.initComponent; let originalInitComponent = WikiBrowserPanel.prototype.initComponent;
WikiBrowserPanel.prototype.initComponent = function() { WikiBrowserPanel.prototype.initComponent = function() {
original.apply(this, arguments);
this.on("treeDataLoaded", function() { this.on("treeDataLoaded", function() {
this.treePanel.store.sort({sorterFn: wikiNodeSort}); this.treePanel.store.sort({sorterFn: wikiNodeSort});
}); });
originalInitComponent.apply(this, arguments);
} }
let originalRenderLayout = WikiBrowserPanel.prototype.renderLayout;
WikiBrowserPanel.prototype.renderLayout = function() {
originalRenderLayout.apply(this, arguments);
try {
this.treePanel.store.sort({sorterFn: wikiNodeSort});
} catch (e) {
// /Communicate/SchoolDocumentation.aspx dies for some reason
}
};
} }