-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YR: added author. Topdesk: Added userscript that copies the issue num…
…ber to clipboard if you click it
- Loading branch information
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // ==UserScript== | ||
| // @name TopDesk - Copy Issuenumber | ||
| // @namespace http://tampermonkey.net/ | ||
| // @version 1.0 | ||
| // @author on@ntnu.no | ||
| // @description Copies the issue number if you click it in TopDesk | ||
| // @match *://*/* | ||
| // @grant none | ||
| // @updateURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/topdesk.user.js | ||
| // @downloadURL https://git.ntnu.no/M365-Drift/MonkeyMagic/raw/main/topdesk.user.js | ||
| // ==/UserScript== | ||
|
|
||
| (function() { | ||
| 'use strict'; | ||
|
|
||
| // Function to copy text to clipboard | ||
| function copyToClipboard(text) { | ||
| const textarea = document.createElement('textarea'); | ||
| textarea.value = text; | ||
| document.body.appendChild(textarea); | ||
| textarea.select(); | ||
| document.execCommand('copy'); | ||
| document.body.removeChild(textarea); | ||
| } | ||
|
|
||
| // Function to show a fading message box | ||
| function showMessage(message) { | ||
| const messageBox = document.createElement('div'); | ||
| messageBox.textContent = message; | ||
| messageBox.style.position = 'fixed'; | ||
| messageBox.style.bottom = '20px'; | ||
| messageBox.style.left = '50%'; | ||
| messageBox.style.transform = 'translateX(-50%)'; | ||
| messageBox.style.backgroundColor = '#333'; | ||
| messageBox.style.color = '#fff'; | ||
| messageBox.style.padding = '10px 20px'; | ||
| messageBox.style.borderRadius = '5px'; | ||
| messageBox.style.zIndex = '10000'; | ||
| messageBox.style.opacity = '1'; | ||
| messageBox.style.transition = 'opacity 2s ease-out'; | ||
| document.body.appendChild(messageBox); | ||
|
|
||
| setTimeout(() => { | ||
| messageBox.style.opacity = '0'; | ||
| setTimeout(() => { | ||
| document.body.removeChild(messageBox); | ||
| }, 2000); | ||
| }, 2000); | ||
| } | ||
|
|
||
| // Find the first div tag and modify its id | ||
| const firstDiv = document.querySelector('div'); | ||
| if (firstDiv && firstDiv.id) { | ||
| const modifiedId = firstDiv.id.slice(0, -1) + '8'; | ||
| const targetDiv = document.getElementById(modifiedId); | ||
| if (targetDiv) { | ||
| targetDiv.addEventListener('click', function() { | ||
| const content = targetDiv.textContent || targetDiv.innerText; | ||
| copyToClipboard(content); | ||
| showMessage('\'' + content + '\' copied to clipboard!'); | ||
| }); | ||
| } | ||
| } | ||
| })(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters