Last active
March 27, 2024 22:16
-
-
Save carlos-moura/36319fe550d53f2f573bc08510e0865a to your computer and use it in GitHub Desktop.
TOPdesk Copy URL plugin
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
// ==UserScript== | |
// @name TopDesk Copy Issue URL | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description try to take over the world! | |
// @author You | |
// @match *://*.topdesk.net/* | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.5.0.min.js | |
// ==/UserScript== | |
jQuery(function ($) { | |
if ($('h1[lmask] div').first().length) { | |
var issueId = $('h1[lmask] div').first().text(); | |
//console.log('issueId', issueId); | |
} | |
var $btnSalvar = $('div[aria-label^="Save (Alt+S)"], div[aria-label^="Salvar (Alt+S)"]'); | |
if ($btnSalvar.length) { | |
//console.log('save button', $btnSalvar.parent().parent()); | |
$btnSalvar | |
.parent() | |
.parent() | |
.prepend('<div class="a0 b0 c0 d0 e1 h10 i5 k1 l1 btnCopy" lmask="[FG][FL][MC]" mpar="cC5_D" mtype="group" \ | |
data-issueid="' + issueId + '" \ | |
style="display:block;visibility:visible;top:0px;left: -70px;width:57px;height:32px;"> \ | |
<div aria-label="Copy" class="a0 b0 c0 d0 e1 f6 g13 h5 i5 j6 k2 l1" \ | |
style="display:block;visibility:visible;top:0px;left:0px;width:31px;height:24px;background-color:#f60;border-color:#f60"> \ | |
<div class="a0 b1 c0 d0 e1 h10 i3 k2 l0 copyText" \ | |
style="display:block;visibility:visible;top:3px;left:12px;width:31px;height:24px;line-height:24px;overflow:hidden;white-space:nowrap;color:white"> \ | |
Copy \ | |
</div> \ | |
</div> \ | |
</div>'); | |
} | |
$('.btnCopy').on('click', function () { | |
var $btnCopy = $(this), | |
issueUrl = 'https://' + window.location.hostname + '/tas/secure/incident?action=lookup&lookup=naam&lookupValue=' + $btnCopy.data('issueid'); | |
navigator.clipboard.writeText(issueUrl) | |
.then(() => { | |
$btnCopy.find('.copyText').text('✔'); | |
setTimeout(function () { | |
$btnCopy.find('.copyText').text('Copy'); | |
}, 1000); | |
}) | |
.catch(err => { | |
alert("Could not copy text:\n" + err); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How du I use this Addon?
Cant find any Button to copy the URL.
I'm Using Edge Version 102, Tampermonkey 4.16.1, TOPdesk 11.04.014 (on premises).
I added the URL of my Topdesk installation to the @match section in the Script.