Skip to content

Commit

Permalink
should not match stuff inside code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Jan 20, 2025
1 parent f6b522f commit f94e1d0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fuglane.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Fuglane - Issue links
// @namespace http://tampermonkey.net/
// @version 1.3.1
// @version 1.3.2
// @description Replace NTNU issue numbers, change numbers and upn's with clickable links to TopDesk
// @author Øyvind Nilsen (on@ntnu.no)
// @match https://fuglane.it.ntnu.no/*
Expand All @@ -22,6 +22,8 @@
const emailRegex = /([a-z0-9-_]{2,40})(?:@ntnu\.no)/gi;
const text = node.textContent;

console.log("TEXT: " + text);

let replacedText = text.replace(incidentRegex, (match) => {
const url = `https://hjelp.ntnu.no/tas/secure/incident?action=lookup&lookup=naam&lookupValue=${match}`;
return `<a href="${url}" target="_blank">${match}</a>`;
Expand All @@ -42,7 +44,7 @@
span.innerHTML = replacedText;
node.parentNode.replaceChild(span, node);
}
} else if (node.nodeType === Node.ELEMENT_NODE && node.nodeName !== 'SCRIPT' && node.nodeName !== 'STYLE') {
} else if (node.nodeType === Node.ELEMENT_NODE && node.nodeName !== 'SCRIPT' && node.nodeName !== 'STYLE' && !node.className.includes('syntaxhighlighter')) {
for (let i = 0; i < node.childNodes.length; i++) {
replaceTextWithLinks(node.childNodes[i]);
}
Expand Down

0 comments on commit f94e1d0

Please sign in to comment.