Toggl-Button Drupal

Toggle button for Drupal issue queues

  1. // ==UserScript==
  2. // @name Toggl-Button Drupal
  3. // @namespace https://gitlab.paragon-es.de/toggl-button
  4. // @version 1.6
  5. // @include https://www.drupal.org/node/*
  6. // @include https://www.drupal.org/project/issues/*
  7. // @include https://www.drupal.org/project/user
  8. // @include https://drupal.org/node/*
  9. // @include https://drupal.org/project/issues/*
  10. // @include https://drupal.org/project/user
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_addStyle
  13. // @grant GM_getResourceText
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // @grant GM_info
  17. // @grant GM_registerMenuCommand
  18. // @require https://gf.qytechs.cn/scripts/2670-toggllibrary/code/TogglLibrary.js
  19. // @resource togglStyle https://gitlab.paragon-es.de/toggl-button/core/raw/master/TogglLibrary.css
  20. // @description Toggle button for Drupal issue queues
  21. // ==/UserScript==
  22.  
  23. new TogglButtonGM('body.node-type-project-issue', function (elem) {
  24. var description, projectIds = [],
  25. href = document.getElementById('tabs').getElementsByTagName('a')[0].getAttribute('href'),
  26. id = href.match(/(?:node|comment\/reply)\/(\d+)/)[1],
  27. titleElem = elem.querySelector('#page-subtitle', elem),
  28. projectElem = document.querySelector('.field-name-field-project .field-items .field-item');
  29.  
  30. description = titleElem.textContent.trim();
  31. if (id !== null) {
  32. description = id + " " + description;
  33. }
  34.  
  35. if (projectElem !== null) {
  36. projectIds.push(projectElem.textContent.trim());
  37. }
  38.  
  39. return {
  40. className: 'drupal',
  41. description: description,
  42. projectIds: projectIds
  43. };
  44. });
  45.  
  46. new TogglButtonGM('body.page-project-issues table.views-table tbody tr', function (elem) {
  47. var description, projectIds = [],
  48. href = elem.querySelector('td.views-field-title a').getAttribute('href'),
  49. id = href.match(/(?:node|comment\/reply)\/(\d+)/)[1],
  50. titleElem = elem.querySelector('td.views-field-title a'),
  51. projectElem = document.querySelector('.breadcrumb a');
  52.  
  53. description = titleElem.textContent.trim();
  54. if (id !== null) {
  55. description = id + " " + description;
  56. }
  57.  
  58. if (projectElem !== null) {
  59. projectIds.push(projectElem.textContent.trim());
  60. }
  61.  
  62. return {
  63. className: 'drupal',
  64. description: description,
  65. projectIds: projectIds,
  66. buttonType: 'minimal',
  67. targetSelectors: {
  68. context: elem,
  69. link: '.views-field-field-issue-assigned',
  70. projectSelect: '.views-field-created'
  71. }
  72. };
  73. });
  74.  
  75. new TogglButtonGM('body.page-project-user .view-content table.views-table.project-issue tbody tr', function (elem) {
  76. var description, projectIds = [],
  77. href = elem.querySelector('td.views-field-title a').getAttribute('href'),
  78. id = href.match(/(?:node|comment\/reply)\/(\d+)/)[1],
  79. titleElem = elem.querySelector('td.views-field-title a'),
  80. projectElem = elem.querySelector('td.views-field-title-1 a');
  81.  
  82. description = titleElem.textContent.trim();
  83. if (id !== null) {
  84. description = id + " " + description;
  85. }
  86.  
  87. if (projectElem !== null) {
  88. projectIds.push(projectElem.textContent.trim());
  89. }
  90.  
  91. return {
  92. className: 'drupal',
  93. description: description,
  94. projectIds: projectIds,
  95. buttonType: 'minimal',
  96. targetSelectors: {
  97. context: elem,
  98. link: '.views-field-name',
  99. projectSelect: '.views-field-created'
  100. }
  101. };
  102. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址