Trello

Trello Filter Estimate or Not

当前为 2018-02-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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;
                    }
                });
            });
        });
    });
})();