From 65a219c84427cd6715a15ad48bbd10c29949a248 Mon Sep 17 00:00:00 2001 From: blankie Date: Mon, 18 Mar 2024 14:54:45 +1100 Subject: [PATCH] Update Compass QoL Enhancer to 1.29.0 - Fix opening links with ampersands submitted in Learning Tasks --- Compass QoL Enhancer.user.js | 31 +++++++++++++++++-------------- README.md | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Compass QoL Enhancer.user.js b/Compass QoL Enhancer.user.js index b435ecb..8bf0fd5 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.28.0 +// @version 1.29.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 @@ -129,16 +129,18 @@ function handleNewsItemClick(event) { this.expandTruncated(); } } +function handleNewsItem(newsItem) { + if (!newsItem.priority) { + return; + } + let img = document.createElement("img"); + img.src = `${newsItem.m_AssetPath}Pix/16x16/flag_orange.png`; + img.classList.add("priority-flag"); + img.dataset.qtip = "This news item has been flagged as important"; + newsItem.newsItemDetails.el.dom.querySelector("div > span > div > span").append(img); +} let NewsfeedItemWidget = getExtClass("Compass.widgets.NewsfeedItemWidget"); if (NewsfeedItemWidget) { - function addImportantFlag(newsItem) { - let img = document.createElement("img"); - img.src = `${newsItem.m_AssetPath}Pix/16x16/flag_orange.png`; - img.classList.add("priority-flag"); - img.dataset.qtip = "This news item has been flagged as important"; - newsItem.newsItemDetails.el.dom.querySelector("div > span > div > span").append(img); - } - let originalRenderLayout = NewsfeedItemWidget.prototype.renderLayout; NewsfeedItemWidget.prototype.renderLayout = function() { originalRenderLayout.apply(this, arguments); @@ -148,9 +150,7 @@ if (NewsfeedItemWidget) { // Expand news feed items by clicking on them this.el.on("click", handleNewsItemClick.bind(this), this.el); // Add important flag to priority news items - if (this.priority) { - addImportantFlag(this); - } + handleNewsItem(this); }); } @@ -597,7 +597,10 @@ function handleLearningTaskSubmissionTable(element) { if (item.submissionFileType === LearningTasksSubmissionFileType.File) { url = `/Services/FileDownload/FileRequestHandler?FileDownloadType=2&taskId=${taskId}&submissionId=${item.id}`; } else if (item.submissionFileType === LearningTasksSubmissionFileType.SubmissionUrl) { - url = item.fileName; + // Fix opening submitted links with ampersands + let parser = new DOMParser(); + let document = parser.parseFromString(item.fileName, "text/html"); + url = document.documentElement.textContent; } else { continue; } @@ -827,7 +830,7 @@ if (unsafeWindow.CKEDITOR) { for (let attr of script.attributes) { scriptClone.setAttribute(attr.name, attr.value); } - scriptClone.innerText = script.innerText; + scriptClone.innerText = script.textContent; script.replaceWith(scriptClone); } this.$.dispatchEvent(new Event("DOMContentLoaded")); diff --git a/README.md b/README.md index 2d04d4e..f86b29a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ A userscript that adds small but useful features for Compass. Features are: permission information) - File upload buttons now work with [Link Hints] - Fix submitting links by simply pressing Enter +- Fix opening links with ampersands submitted in Learning Tasks - Links inside lesson plans now open in the parent tab by default instead of creating a new tab - Files and links submitted to learning tasks are now actual links (they now