Skip to content

Commit

Permalink
Fixed the bug where html was not copied the first time an issue numbe…
Browse files Browse the repository at this point in the history
…r was clicked
  • Loading branch information
on committed Oct 3, 2025
1 parent 8af4bc8 commit 01c7894
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/topdesk/topdesk.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TopDesk - Copy Issuenumber
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/
// @version 1.2.3
// @version 1.2.4
// @author Øyvind Nilsen (on@ntnu.no)
// @description Copies the issue number if you click it in TopDesk or with the hotkey `ctrl` + `alt` + `c`. It copies plain text and a clickable HTML version. So if the place you paste supports HTML, you can paste a clickable link to the issue.
// @match https://hjelp.ntnu.no/tas/secure/mango/window/*
Expand All @@ -16,8 +16,8 @@
'use strict';

// Regex patterns
const incidentRegex = /(NTNU[0-9]{7})/gi;
const changeRegex = /(NTNU_C[0-9]{7})/gi;
const incidentRegex = /(NTNU[0-9]{7})/i;
const changeRegex = /(NTNU_C[0-9]{7})/i;
//const issueRegex = /(NTNU(?:_C)?[0-9]{7})/gi;

// Function to copy text to clipboard
Expand Down Expand Up @@ -100,14 +100,14 @@

// Replace incident matches
if (incidentRegex.test(content)) {
newContent = newContent.replace(incidentRegex, (match) => {
newContent = newContent.replace(/(NTNU[0-9]{7})/gi, (match) => {
return `<a href="https://hjelp.ntnu.no/tas/secure/incident?action=lookup&lookup=naam&lookupValue=${match}" target="_blank">${match}</a>`;
});
}

// Replace change matches
if (changeRegex.test(content)) {
newContent = newContent.replace(changeRegex, (match) => {
newContent = newContent.replace(/(NTNU_C[0-9]{7})/gi, (match) => {
return `<a href="https://hjelp.ntnu.no/tas/secure/newchange?action=lookup&lookup=number&lookupValue=${match}" target="_blank">${match}</a>`;
});
}
Expand Down

0 comments on commit 01c7894

Please sign in to comment.