Skip to content

Instantly share code, notes, and snippets.

@manuc66
Last active May 22, 2022 22:28
Show Gist options
  • Save manuc66/52a6d6674bb075fe60d4acd869b5cbd9 to your computer and use it in GitHub Desktop.
Save manuc66/52a6d6674bb075fe60d4acd869b5cbd9 to your computer and use it in GitHub Desktop.
Jira key & summary to Clipboard for commit log
// ==UserScript==
// @name Jira key & summary to Clipboard for commit log
// @namespace sremy
// @version 2.0.1
// @description Quick copy of task key and summary from JIRA to clipboard (for commit)
// @author Sébastien REMY, Emmanuel Counasse
// @match https://jira.atlassian.com/browse/*
// @match https://jira.*/browse/*
// @require https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js
// @require https://cdn.jsdelivr.net/npm/notify-js-legacy@0.4.1/notify.min.js
// ==/UserScript==
var $ = jQuery; // or https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
let clipboard = new ClipboardJS('#clipboardBtn', {
text: function(trigger) {
return $('#key-val').text() + ' - ' + $('#summary-val').text();
}
});
clipboard.on('success', function(e) {
$.notify("Copied to clipboard. " + e.text, "info");
});
clipboard.on('error', function(e) {
$.notify("Failed to copy", "error");
});
function init() {
'use strict';
if(!$('#clipboardBtn').length) {
$('.aui-toolbar2-primary').append("<button id='clipboardBtn' class='aui-button aui-style'><img style='display: block;' src='https://clipboardjs.com/assets/images/clippy.svg' width='15' alt='Copy key and title to clipboard'></button>");
}
}
$(document).ajaxComplete(init);
@manuc66
Copy link
Author

manuc66 commented Jul 22, 2020

wider matching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment