Trello

Trello Filter Estimate or Not

目前为 2018-02-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Trello
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Trello Filter Estimate or Not
  6. // @description:en Trello Filter Estimate or Not
  7. // @author Tguillaume
  8. // @match https://trello.com/*
  9. // @require http://code.jquery.com/jquery-latest.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. $(document).ready(function() {
  15. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyEstimate" class="header-btn-text"> Only Estimate </span></a>');
  16. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyNotEstimate" class="header-btn-text"> Only Not Estimate </span></a>');
  17. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="all" class="header-btn-text"> All </span></a>');
  18.  
  19. /// GET FILTER ///
  20. function getFilter()
  21. {
  22. filter = [];
  23. $(".label-list-item.is-active").each(function(index){
  24. filter.push($(this).find("span.label-list-item-link-name").text());
  25. });
  26. }
  27.  
  28. $("#onlyEstimate").click(function() {
  29. getFilter();
  30. $(".badge.badge-points.point-count").each(function(index)
  31. {
  32. if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() != "")
  33. {
  34. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
  35. if (filter.length > 0 )
  36. {
  37. if ($.inArray($(this).text(), filter) >= 0)
  38. {
  39. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  40. return false;
  41. }
  42. else
  43. {
  44. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  45. }
  46. }
  47. else
  48. {
  49. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  50. return false;
  51. }
  52. });
  53. }
  54. else
  55. {
  56. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  57. }
  58. });
  59. });
  60.  
  61. $("#onlyNotEstimate").click(function() {
  62. getFilter();
  63. $(".badge.badge-points.point-count").each(function(index){
  64. if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() == "")
  65. {
  66. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
  67. if (filter.length > 0)
  68. {
  69. if ($.inArray($(this).text(), filter) >= 0)
  70. {
  71. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  72. return false;
  73. }
  74. else
  75. {
  76. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  77. }
  78. }
  79. else
  80. {
  81. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  82. return false;
  83. }
  84. });
  85. }
  86. else
  87. {
  88. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  89. }
  90. });
  91. });
  92.  
  93.  
  94. $("#all").click(function() {
  95. getFilter();
  96. $(".list-card-title").each(function(index)
  97. {
  98. $(this).parent().find(".mod-card-front").each(function(i){
  99. if (filter.length > 0)
  100. {
  101. if ($.inArray($(this).text(), filter) >= 0)
  102. {
  103. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  104. return false;
  105. }
  106. else
  107. {
  108. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  109. }
  110. }
  111. else
  112. {
  113. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  114. return false;
  115. }
  116. });
  117. });
  118. });
  119. });
  120. })();