diff --git a/topdesk.user.js b/topdesk.user.js
index 822d09b..d1ed5b0 100644
--- a/topdesk.user.js
+++ b/topdesk.user.js
@@ -1,7 +1,7 @@
// ==UserScript==
// @name TopDesk - Copy Issuenumber
// @namespace https://git.ntnu.no/M365-Drift/MonkeyMagic/
-// @version 1.1.3
+// @version 1.1.4
// @author Øyvind Nilsen (on@ntnu.no)
// @description Copies the issue number if you click it in TopDesk. 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/*
@@ -72,34 +72,38 @@
const targetDiv = document.getElementById(modifiedId);
if (targetDiv) {
- targetDiv.style.cursor = "copy";
- targetDiv.addEventListener('click', function() {
- const content = targetDiv.textContent || targetDiv.innerText;
- let newContent = content;
+ const content = targetDiv.textContent || targetDiv.innerText;
+ // Only add the event listener if the content contains an incident or change number:
+ if (incidentRegex.test(content) || changeRegex.test(content)) {
+ targetDiv.style.cursor = "copy";
+ targetDiv.addEventListener('click', function() {
+
+ let newContent = content;
- // Replace incident matches
- if (incidentRegex.test(content)) {
- newContent = newContent.replace(incidentRegex, (match) => {
- return `${match}`;
- });
- }
+ // Replace incident matches
+ if (incidentRegex.test(content)) {
+ newContent = newContent.replace(incidentRegex, (match) => {
+ return `${match}`;
+ });
+ }
- // Replace change matches
- if (changeRegex.test(content)) {
- newContent = newContent.replace(changeRegex, (match) => {
- return `${match}`;
- });
- }
+ // Replace change matches
+ if (changeRegex.test(content)) {
+ newContent = newContent.replace(changeRegex, (match) => {
+ return `${match}`;
+ });
+ }
- // Only update and copy if there were changes
- if (newContent !== content) {
- // Copy the updated content to clipboard
- copyToClipboard(newContent, content);
- } else {
- copyToClipboard(null, content);
- }
- showMessage('\'' + content + '\' copied to clipboard!');
- });
+ // Only update and copy if there were changes
+ if (newContent !== content) {
+ // Copy the updated content to clipboard
+ copyToClipboard(newContent, content);
+ } else {
+ copyToClipboard(null, content);
+ }
+ showMessage('\'' + content + '\' copied to clipboard!');
+ });
+ }
}
}
})();
\ No newline at end of file