Trello

Trello Filter Estimate or Not

  1. // ==UserScript==
  2. // @name Trello
  3. // @namespace https://greasyfork.org/fr/scripts/38702-trello
  4. // @version 0.2
  5. // @description Trello Filter Estimate or Not
  6. // @author Tguillaume
  7. // @match https://trello.com/*
  8. // @require http://code.jquery.com/jquery-latest.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. $(document).ready(function() {
  14. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyEstimate" class="header-btn-text"> Only Estimate </span></a>');
  15. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyNotEstimate" class="header-btn-text"> Only Not Estimate </span></a>');
  16. $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="all" class="header-btn-text"> All </span></a>');
  17.  
  18. /// GET FILTER ///
  19. function getFilter()
  20. {
  21. //filter = getUrlParameter('filter').split(",");
  22. filter = [];
  23. filterUser = [];
  24. $(".label-list-item.is-active").each(function(index){
  25. filter.push($(this).find("span.label-list-item-link-name").text());
  26. });
  27.  
  28. $(".item.active.js-member-item").each(function(index){
  29. filterUser.push($(this).find("span.username").text());
  30. });
  31. }
  32.  
  33. /* function getUrlParameter(sParam) {
  34. var sPageURL = decodeURIComponent(window.location.search.substring(1)),
  35. sURLVariables = sPageURL.split('&'),
  36. sParameterName,
  37. i;
  38.  
  39. for (i = 0; i < sURLVariables.length; i++) {
  40. sParameterName = sURLVariables[i].split('=');
  41.  
  42. if (sParameterName[0] === sParam) {
  43. return sParameterName[1] === undefined ? true : sParameterName[1].replace(/\label:/g, '').replace(/\@/g, '');
  44. }
  45. }
  46. }*/
  47.  
  48.  
  49. function checkUser(attr)
  50. {
  51. bUser = true;
  52. if (filterUser.length > 0)
  53. {
  54. bUser = false;
  55. $(attr).parent().parent().find(".member-avatar").each(function(z){
  56. user = $(this);
  57. $.each(filterUser, function (i,v){
  58. if (user.attr("title").indexOf(v) > 0)
  59. {
  60. bUser = true;
  61. return false;
  62. }
  63. });
  64. });
  65. }
  66. }
  67.  
  68. $("#onlyEstimate").click(function() {
  69. getFilter();
  70. $(".badge.badge-points.point-count").each(function(index)
  71. {
  72. if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() != "")
  73. {
  74. // Search card with filter service
  75. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
  76. if (filter.length > 0 || filterUser.length > 0)
  77. {
  78. checkUser($(this));
  79. if (($.inArray($(this).text(), filter) >= 0 && bUser == true) || (filter.length == 0 && bUser == true))
  80. {
  81. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  82. return false;
  83. }
  84. else
  85. {
  86. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  87. }
  88. }
  89. else
  90. {
  91. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  92. return false;
  93. }
  94. });
  95. }
  96. else
  97. {
  98. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  99. }
  100. });
  101. });
  102.  
  103. $("#onlyNotEstimate").click(function() {
  104. getFilter();
  105. $(".badge.badge-points.point-count").each(function(index){
  106. if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() == "")
  107. {
  108. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
  109. if (filter.length > 0 || filterUser.length > 0)
  110. {
  111. checkUser($(this));
  112. if (($.inArray($(this).text(), filter) >= 0 && bUser == true) || (filter.length == 0 && bUser == true))
  113. {
  114. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  115. return false;
  116. }
  117. else
  118. {
  119. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  120. }
  121. }
  122. else
  123. {
  124. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  125. return false;
  126. }
  127. });
  128. }
  129. else
  130. {
  131. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  132. }
  133. });
  134. });
  135.  
  136.  
  137. $("#all").click(function() {
  138. getFilter();
  139. $(".list-card-title").each(function(index){
  140. $(this).parent().find(".mod-card-front").each(function(i){
  141. if (filter.length > 0 || filterUser.length > 0)
  142. {
  143. checkUser($(this));
  144. if (($.inArray($(this).text(), filter) >= 0 && bUser == true) || (filter.length == 0 && bUser == true))
  145. {
  146. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  147. return false;
  148. }
  149. else
  150. {
  151. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
  152. }
  153. }
  154. else
  155. {
  156. $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
  157. return false;
  158. }
  159. });
  160. });
  161. });
  162. });
  163. })();