Redmine category links

Project URL: https://github.com/JanisE/greasemonkey-redmine-category_links

  1. // ==UserScript==
  2. // @name Redmine category links
  3. // @namespace https://github.com/JanisE
  4. // @description Project URL: https://github.com/JanisE/greasemonkey-redmine-category_links
  5. // @include /redmine.*\..{2,3}\/.*/
  6. // @version 1.1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. function exec (fn)
  11. {
  12. var script = document.createElement('script');
  13. script.setAttribute("type", "application/javascript");
  14. script.textContent = '(' + fn + ')();';
  15. document.body.appendChild(script); // run the script
  16. document.body.removeChild(script); // clean up
  17. }
  18.  
  19. exec(function ()
  20. {
  21. var sCategory = $('.category .value').text();
  22. var iCategory = false;
  23. $('#issue_category_id option').each(function ()
  24. {
  25. var jqOption = $(this);
  26. if (jqOption.text() == sCategory) {
  27. iCategory = jqOption.prop('value');
  28. }
  29. });
  30.  
  31. if (iCategory) {
  32. $('a.issues').prop('href');
  33. $('.category .value')
  34. .empty()
  35. .append(
  36. $('<a></a>')
  37. .text(sCategory)
  38. .prop('href', $('a.issues').prop('href') + '?set_filter=1&f[]=category_id&op[category_id]=%3D&v[category_id][]=' + iCategory)
  39. );
  40. }
  41. });