NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Elementool Quick Copy Link
// @version 0.4
// @description Inserts a copy link next to the ticket number to get a shareable link for Elementool Tickets.
// @author Florian
// @license MIT
// @include https://www.elementool.com/Services/BugTracking/*
// @include https://www.elementool.com/services/common/SubmitResult*
// ==/UserScript==
var zNode = document.createElement('div');
zNode.innerHTML = '<button id="myButton" class="no_border" type="button">' +
'Copy Link</button>';
zNode.setAttribute('id', 'myContainer');
zNode.setAttribute("color", "#3c89c3");
if (document.getElementById("lblIssueNo") != null) {
document.getElementById("lblIssueNo").appendChild(zNode); //existing ticket
document.getElementById("myButton").addEventListener(
"click", ButtonClickAction, false
);
}
if (document.getElementById("Result_pnlResult") != null) {
document.getElementById("Result_pnlResult").appendChild(zNode); //submit - to be verified
document.getElementById("myButton").addEventListener(
"click", ButtonClickAction2, false
);
}
function ButtonClickAction(zEvent) {
var full_title = document.title;
var re = /Issue #(\d*) - elementool - (\w*) :: ((\w|\W)*)/;
var found = re.exec(full_title);
var ticketId = found[1];
var account = found[2];
var newURL = "http://www.elementool.com/Services/Common/quickview.aspx?accntname=".concat(account, "&issueno=", ticketId);
//zNode.innerHTML = newURL;
copy(newURL);
}
function ButtonClickAction2(zEvent) {
var full_title = document.title; // elementool - BSGermany :: PSM-Germany
var re = /elementool - (\w*) :: ((\w|\W)*)/;
var found = re.exec(full_title);
var ticketId = document.getElementById("Result_lnkIssue").text;
var account = found[1];
var newURL = "http://www.elementool.com/Services/Common/quickview.aspx?accntname=".concat(account, "&issueno=", ticketId);
console.log(newURL);
//zNode.innerHTML = newURL;
copy(newURL);
}
function copy(my_text) {
/* Get the text field */
navigator.clipboard.writeText(my_text).then(function () {
console.log('Async: Copying to clipboard was successful!');
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}