diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index fad8bba..5c2e2e4 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.19.0 +// @version 1.19.1 // @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 @@ -242,13 +242,23 @@ function wikiNodeSort(lhs, rhs) { } let WikiBrowserPanel = getExtClass("Compass.widgets.WikiBrowserPanel"); if (WikiBrowserPanel) { - let original = WikiBrowserPanel.prototype.initComponent; + let originalInitComponent = WikiBrowserPanel.prototype.initComponent; WikiBrowserPanel.prototype.initComponent = function() { - original.apply(this, arguments); this.on("treeDataLoaded", function() { 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 + } + }; }