Update Compass QoL Enhancer to 1.13.1

- Tabs specified in the URL are now opened as fast as possible
- Fix some panels not having their tabs linked to
This commit is contained in:
blankie 2023-09-01 11:26:10 +10:00
parent 169205b341
commit b251d9c2e5
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 16 additions and 8 deletions

View File

@ -2,7 +2,7 @@
// @name Compass QoL Enhancer
// @namespace blankie-scripts
// @match http*://*.compass.education/*
// @version 1.13.0
// @version 1.13.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
@ -223,15 +223,19 @@ function handleNewCalendarEvent(element, calendar) {
function handlePanelItem(panel, panelItem, isDefault, tabToOpen) {
let panelId = panelItem.itemId || panelItem.id;
let panelItemHash = getPanelItemHash(panelId, isDefault);
// Automatically open tab specified in fragment
if (panelId === tabToOpen) {
// if the sessions tab is automatically opened, the currently selected tab is still dashboard for some reason
// i can't be arsed to read any more minified javascript, so this is the best fix that you'll get
// it does look like that this bug only manifests if the tab is activated while the initial loading thing is shown
setTimeout(function() {
// if the sessions tab is automatically opened, the currently selected tab is still dashboard for some reason,
// hence this hook to open it when the dashboard finishes loading
if (panel.setDashboardToLoading) {
let original = panel.setDashboardToLoading;
panel.setDashboardToLoading = function(loading) {
original.apply(this, arguments);
!loading && panel.setActiveTab(panelItem);
}
} else {
panel.setActiveTab(panelItem);
}, 1000);
}
}
// /Communicate/SchoolDocumentation.aspx does not have tabs
@ -320,7 +324,11 @@ function handleNewNode(node, observer) {
}
} else if (!qolTabOpened && node.classList.contains("x-panel")) {
qolTabOpened = true;
let panel = unsafeWindow.Ext.getCmp(node.id);
let topMostPanel = node;
while (topMostPanel.parentElement.closest(".x-panel")) {
topMostPanel = topMostPanel.parentElement.closest(".x-panel");
}
let panel = unsafeWindow.Ext.getCmp(topMostPanel.id);
let tabToOpen = window.location.pathname === "/Organise/Activities/Activity.aspx"
? getHashSearch().get("qol_open_tab")
: (window.location.hash.replace(/^#(.+?)&.*$/, "$1") || null);