Redmine Ticket Link

Add link to current ticket.

  1. // ==UserScript==
  2. // @name Redmine Ticket Link
  3. // @description:en Add link to current ticket.
  4. // @version 0.2
  5. // @namespace http://twitter.com/foldrr/
  6. // @require https://code.jquery.com/jquery-1.11.3.min.js
  7. // @require https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.3/clipboard.min.js
  8. // @match http://*/redmine/issues/*
  9. // @description Add link to current ticket.
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. var issue_id = (location.href.match(/issues\/(\d+)/) || [])[1];
  14. if(! issue_id) return;
  15. var issue_title = $('.subject h3').text();
  16. create_link = function(css_class, text, link){
  17. $('<button/>', {
  18. 'text': text,
  19. 'style': 'margin-left: 20px',
  20. 'class': css_class,
  21. 'data-clipboard-text': link
  22. }).appendTo("h2");
  23. };
  24. create_link('copy-button', 'URL', location.href);
  25. create_link('copy-button', 'Markdown', '[#' + issue_id + " " + issue_title + "](" + location.href + ")");
  26. new Clipboard('.copy-button');
  27. })();