NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Jira Agile Task to Clipboard // @version 2.0.4 // @copyright 2020, Milan Farkas / WRD Labs Zrt. (https://www.wrd.hu) // @namespace www.wrd.hu // @description DEPRECATED! This script allows easy copying of Task Key and Title to Clipboard // @author milanfarkas // @license MIT // @include /https?:\/\/jira.*\/browse\/.* // @include /https?:\/\/jira.*\/secure\/RapidBoard.jspa.* // @include /https?:\/\/jira.*\/.*issues.* // @require https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js // @updateURL https://openuserjs.org/meta/milanfarkas/Jira_Agile_Task_to_Clipboard.meta.js // @downloadURL https://openuserjs.org/install/milanfarkas/Jira_Agile_Task_to_Clipboard.user.js // ==/UserScript== $(document).ajaxComplete(() => initPlugin()); let initPlugin = () => { if (!$('#clipboardBtn').length) { $('#ghx-detail-head .ghx-controls').prepend("<button id='clipboardBtn' style='margin-left:0;' class='aui-button copy-task-button aui-button ghx-actions aui-button-compact aui-button-subtle'><span class='icon icon-default aui-icon aui-icon-small aui-iconfont-copy-clipboard'></span> Copy</button>"); $('.aui-toolbar2-secondary').prepend("<div id='opsbar-jira.issue.tools' class='aui-buttons pluggable-ops'><a id='clipboardBtn' href='#' class='copy-task-button aui-button'><span class='icon icon-default aui-icon aui-icon-small aui-iconfont-copy-clipboard'></span> <span>Copy</span></a></div>"); $(".copy-task-button").off("click"); $(".copy-task-button").click(copyTaskKeyAndTitle); } }; let copyTaskKeyAndTitle = () => { let issueKey = $('#key-val').text(); if (issueKey === '') { issueKey = $('#issuekey-val').text(); } const issueTitle = $('#summary-val').text(); const htmlText = "<a href=\"" + new URL("/browse/" + issueKey, document.baseURI).href + "\">" + issueKey + "</a> " + issueTitle; const plainText = issueKey + ' ' + issueTitle; copyToClipboard(htmlText, plainText); $.notify(plainText, 'success'); }; let copyToClipboard = (htmlText, plainText) => { function listener(e) { e.clipboardData.setData("text/html", htmlText); e.clipboardData.setData("text/plain", plainText); e.preventDefault(); } document.addEventListener("copy", listener); document.execCommand("copy"); document.removeEventListener("copy", listener); }; (function () { 'use strict'; })();