Copy Redmine task title

Copy Redmine task title to clipboard

Устаревшая версия за 16.05.2019. Перейдите к последней версии.

// ==UserScript==
// @name Copy Redmine task title
// @namespace Redmine
// @icon https://dev.framgia.com/favicon.ico?1528612569
// @description Copy Redmine task title to clipboard
// @run-at document-start
// @match *://dev.sun-asterisk.com/issues/*
// @grant GM_setClipboard
// @grant GM_notification
// @version 1.0
// ==/UserScript==

document.addEventListener("DOMContentLoaded", function(event) {
    let contentEl = $('#content'),
    ticketNumber = contentEl.children('.contextual').siblings('h2').text(),
    ticketTitle = contentEl.find('.subject h3').text(),
    ticketURL = location.protocol + '//' + location.host + location.pathname,
    progress = contentEl.find('.attributes .percent').text(),
    textToCopy = ticketNumber + ' - ' + ticketTitle + ' ' + '(' + ticketURL + ')';

    if (progress.split('%')[0] > 0) {
        contentEl.find('.icon-copy').closest('.contextual').append('<a class="icon icon-copy icon-copy-to-clipboard" href="#">Copy to Clipboard</a>');
        $('.icon-copy-to-clipboard').on('click', function () {
            textToCopy += ' => (' + progress  + ')';
            //GM_setClipboard(textToCopy);
            GM_notification ( {title: 'Redmine copied', text: textToCopy, image: 'https://dev.framgia.com/favicon.ico?1528612569'} );
        });
    }
});