Update Compass QoL Enhancer to 1.24.2
- Fix popups being occluded by the prioritised nav bar - Fix `qol_learning_task` being stripped on /Organise/Activities/Activity.aspx
This commit is contained in:
parent
ed2fbde27a
commit
ed564db7fa
|
@ -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.24.1
|
// @version 1.24.2
|
||||||
// @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
|
||||||
|
@ -15,7 +15,8 @@ let qolTabOpened = false;
|
||||||
let qolLearningTaskOpened = false;
|
let qolLearningTaskOpened = false;
|
||||||
let modifyUrlHash = true;
|
let modifyUrlHash = true;
|
||||||
let shownWindows = 0;
|
let shownWindows = 0;
|
||||||
let productNavBar = document.querySelector("#productNavBar");
|
// popups should bot be blocked by the prioritised nav bar
|
||||||
|
let productNavBar = window.location.pathname !== "/ActionCentre/" ? document.querySelector("#productNavBar") : null;
|
||||||
|
|
||||||
// needed because .toString() adds a trailing = for empty values
|
// needed because .toString() adds a trailing = for empty values
|
||||||
URLSearchParams.prototype.laxToString = function() {
|
URLSearchParams.prototype.laxToString = function() {
|
||||||
|
@ -189,7 +190,7 @@ function handleLearningTaskShow() {
|
||||||
|
|
||||||
let search = getHashSearch();
|
let search = getHashSearch();
|
||||||
search.set("qol_learning_task", this.learningTask.data.id);
|
search.set("qol_learning_task", this.learningTask.data.id);
|
||||||
history.pushState("", "", `#${search.laxToString()}`);
|
window.location.hash = `#${search.laxToString()}`;
|
||||||
}
|
}
|
||||||
function handleLearningTaskClose() {
|
function handleLearningTaskClose() {
|
||||||
if (!modifyUrlHash) {
|
if (!modifyUrlHash) {
|
||||||
|
@ -198,7 +199,7 @@ function handleLearningTaskClose() {
|
||||||
|
|
||||||
let search = getHashSearch();
|
let search = getHashSearch();
|
||||||
search.delete("qol_learning_task");
|
search.delete("qol_learning_task");
|
||||||
history.pushState("", "", `#${search.laxToString()}`);
|
window.location.hash = `#${search.laxToString()}`;
|
||||||
}
|
}
|
||||||
let LearningTasksSubmissionWidget = getExtClass("Compass.widgets.LearningTasksSubmissionWidget");
|
let LearningTasksSubmissionWidget = getExtClass("Compass.widgets.LearningTasksSubmissionWidget");
|
||||||
if (LearningTasksSubmissionWidget) {
|
if (LearningTasksSubmissionWidget) {
|
||||||
|
@ -223,6 +224,17 @@ function updateInstanceButton(instanceDetails, instanceButton, offset) {
|
||||||
}
|
}
|
||||||
let InstanceDetailsWidget = getExtClass("Compass.widgets.InstanceDetailsWidget");
|
let InstanceDetailsWidget = getExtClass("Compass.widgets.InstanceDetailsWidget");
|
||||||
if (InstanceDetailsWidget) {
|
if (InstanceDetailsWidget) {
|
||||||
|
// recreation of updateURLHash to fix qol_learning_task being stripped
|
||||||
|
// example: /Organise/Activities/Activity.aspx#activity/67672&openLearningTaskTab&qol_learning_task=77334
|
||||||
|
InstanceDetailsWidget.prototype.updateURLHash = function(useInstanceId) {
|
||||||
|
let match = window.location.hash.match(/^#.*?[?&](.+)$/);
|
||||||
|
let hash = useInstanceId ? `session/${this.m_instanceId}` : `activity/${this.m_activityId}`;
|
||||||
|
if (match) {
|
||||||
|
hash += `&${match[1]}`;
|
||||||
|
}
|
||||||
|
window.location.hash = `#${hash}`;
|
||||||
|
};
|
||||||
|
|
||||||
let originalUpdateInstanceHeader = InstanceDetailsWidget.prototype.updateInstanceHeader;
|
let originalUpdateInstanceHeader = InstanceDetailsWidget.prototype.updateInstanceHeader;
|
||||||
InstanceDetailsWidget.prototype.updateInstanceHeader = function() {
|
InstanceDetailsWidget.prototype.updateInstanceHeader = function() {
|
||||||
originalUpdateInstanceHeader.apply(this, arguments);
|
originalUpdateInstanceHeader.apply(this, arguments);
|
||||||
|
@ -463,9 +475,9 @@ function handlePanelItem(panel, panelItem, isDefault, tabToOpen) {
|
||||||
}
|
}
|
||||||
// prevent the browser from scrolling to the body
|
// prevent the browser from scrolling to the body
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (modifyUrlHash && window.location.hash !== panelItemHash && (window.location.pathname === "/Organise/Activities/Activity.aspx" || !window.location.hash.startsWith(`${panelItemHash}&`))) {
|
if (modifyUrlHash && (window.location.pathname === "/Organise/Activities/Activity.aspx" || !window.location.hash.startsWith(`${panelItemHash}&`))) {
|
||||||
// Automatically add a reference to the tab when it is clicked
|
// Automatically add a reference to the tab when it is clicked
|
||||||
history.pushState("", "", panelItemHash);
|
window.location.hash = panelItemHash;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue