Skip to content

Commit

Permalink
Hyperlinkify work notes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoudkooi committed Feb 22, 2024
1 parent 968a203 commit 94d0ff0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG.md

## 7.3.2.0 (2024-02-22)
Features:
- Detect links in activity (Classic UI) and convert to hyperlinks. Works on page load, and on mouse over of activity label.

Fixes / changes:
- Update dompurify to 3.0.9

## 7.3.1.1 (2024-02-21)
Fixes / changes:
- Fix slash command not showing when not in Next Experience
Expand Down
22 changes: 22 additions & 0 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@ function snuSettingsAdded() {
snuAddSwitchToApplication();
snuOpenWorkflowLink();
snuEnterToFilterSlushBucket();
snuHyperlinkifyWorkNotes();
}

if (snusettings.hasOwnProperty("slashcommands")) {
Expand Down Expand Up @@ -2708,6 +2709,8 @@ function snuAddTechnicalNames() {
cls.style.display = display;
});
}

snuHyperlinkifyWorkNotes();
}

function snuExtendedFieldInfo() {
Expand Down Expand Up @@ -5135,6 +5138,25 @@ function snuBatchRequest(token, requests, callback) {
}


function snuHyperlinkifyWorkNotes() {
let activityLabel = document.querySelector('.activity-stream-label:not(.snuified)')
if (activityLabel) {
activityLabel.classList.add('snuified');
activityLabel.title = "[SN Utils] Mouseover adds hyperlinks in activity stream";
activityLabel.addEventListener("mouseover", snuHyperlinkifyWorkNotes);
}

let urlRegex = /(?<!href=")(https?:\/\/[^\s]+)/g;
document.querySelectorAll('div.sn-card-component .sn-widget-textblock-body:not(.snuified)').forEach(crd => {
let newContent = crd.innerHTML.replace(urlRegex, function (url) {
return '<a href="' + url + '" target="_blank" title="[SN Utils] Converted to hyperlink">' + url + '</a>';
});
crd.innerHTML = DOMPurify.sanitize(newContent, { ADD_ATTR: ['target'] });
crd.classList.add('snuified');
})
}


function snuTest(){

var batchHeaders = [
Expand Down
Loading

0 comments on commit 94d0ff0

Please sign in to comment.