Trello

Trello Filter Estimate or Not

目前為 2018-02-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Trello
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Trello Filter Estimate or Not
// @description:en  Trello Filter Estimate or Not
// @author       Tguillaume
// @match        https://trello.com/*
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// ==/UserScript==

(function() {
    $(document).ready(function() {
        $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyEstimate" class="header-btn-text"> Only Estimate </span></a>');
        $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="onlyNotEstimate" class="header-btn-text"> Only Not Estimate </span></a>');
        $(".board-header").append('<a class="header-btn header-boards js-boards-menu"><span id="all" class="header-btn-text"> All </span></a>');

        /// GET FILTER ///
        function getFilter()
        {
            filter = [];
            $(".label-list-item.is-active").each(function(index){
                filter.push($(this).find("span.label-list-item-link-name").text());
            });
        }

        $("#onlyEstimate").click(function() {
            getFilter();
            $(".badge.badge-points.point-count").each(function(index)
                                                      {
                if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() != "")
                {
                    $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
                        if (filter.length > 0 )
                        {
                            if ($.inArray($(this).text(), filter) >= 0)
                            {
                                $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                                return false;
                            }
                            else
                            {
                                $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
                            }
                        }
                        else
                        {
                            $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                            return false;
                        }
                    });
                }
                else
                {
                    $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
                }
            });
        });

        $("#onlyNotEstimate").click(function() {
            getFilter();
            $(".badge.badge-points.point-count").each(function(index){
                if ($($(".badge.badge-points.point-count").not(".consumed")[index]).text() == "")
                {
                    $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().find(".mod-card-front").each(function(i){
                        if (filter.length > 0)
                        {
                            if ($.inArray($(this).text(), filter) >= 0)
                            {
                                $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                                return false;
                            }
                            else
                            {
                                $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
                            }
                        }
                        else
                        {
                            $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                            return false;
                        }
                    });
                }
                else
                {
                    $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
                }
            });
        });


        $("#all").click(function() {
            getFilter();
            $(".list-card-title").each(function(index)
                                       {
                $(this).parent().find(".mod-card-front").each(function(i){
                    if (filter.length > 0)
                    {
                        if ($.inArray($(this).text(), filter) >= 0)
                        {
                            $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                            return false;
                        }
                        else
                        {
                            $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().hide();
                        }
                    }
                    else
                    {
                        $($(".badge.badge-points.point-count").not(".consumed")[index]).parent().parent().parent().show();
                        return false;
                    }
                });
            });
        });
    });
})();