Toggl-Button Jira

Toggle button for Jira

当前为 2016-08-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Toggl-Button Jira
  3. // @namespace https://gitlab.paragon-es.de/toggl-button
  4. // @version 0.9
  5. // @include http*://*.atlassian.com/browse/*
  6. // @grant GM_xmlhttpRequest
  7. // @grant GM_addStyle
  8. // @grant GM_getResourceText
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_info
  12. // @grant GM_registerMenuCommand
  13. // @require https://greasyfork.org/scripts/2670-toggllibrary/code/TogglLibrary.js
  14. // @resource togglStyle https://gitlab.paragon-es.de/toggl-button/core/raw/master/TogglLibrary.css
  15. // @description Toggle button for Jira
  16. // ==/UserScript==
  17.  
  18. new TogglButtonGM('.issue-header-content', function (elem) {
  19. var description, projectIds = [],
  20. id = elem.querySelector('#key-val'),
  21. titleElem = elem.querySelector('#summary-val'),
  22. projectElem = elem.querySelector('#project-name-val'),
  23. tagsElem = document.querySelector('.labels-wrap-value span'),
  24. tags = [];
  25.  
  26. description = titleElem.textContent.trim();
  27. if (id !== null) {
  28. description = id.textContent.trim() + " " + description;
  29. }
  30.  
  31. if (projectElem !== null) {
  32. projectIds.push(projectElem.textContent.trim());
  33. }
  34.  
  35. if (tagsElem !== null) {
  36. for (var i = 0, element; elements = tagsElem[i]; i++) {
  37. var text = element.textContent.trim();
  38. if (text != 'None') {
  39. tags.push(text);
  40. }
  41. }
  42. }
  43.  
  44. return {
  45. className: 'jira',
  46. description: description,
  47. projectIds: projectIds,
  48. tags: tags
  49. };
  50. });