Trello Only see Subscribed

Add watch-only features to Trello kanbans

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name                Trello Only see Subscribed
// @name:zh-CN          Trello 只看关注
// @namespace           http://www.qs5.org/?trello_only_see
// @version             0.1
// @description         Add watch-only features to Trello kanbans
// @description:zh-CN   给 Trello 看板添加只看关注功能
// @author              ImDong
// @match               https://trello.com/b/*
// @grant               GM_getValue
// @grant               GM_setValue
// ==/UserScript==

(function () {
    'use strict';

    // 添加只看关注按钮
    $('.board-header-btns .js-board-header-subscribed').before('<a class="board-header-btn sub-btn js-board-header-only-subscribed" href="#"><span class="icon-sm icon-subscribe board-header-btn-icon"></span><span class="board-header-btn-text u-text-underline">只看关注</span></a>');

    // 绑定事件
    $('.board-header-btns').on('click', '.js-board-header-only-subscribed', function (e) {
        // 判断查看状态 为 true 则只看关注
        var subscribedStatus = GM_getValue('subscribedStatus', false);
        $(this).find('.board-header-btn-text').text(subscribedStatus ? '只看关注' : '查看全部');
        GM_setValue('subscribedStatus', !subscribedStatus);

        if (subscribedStatus) {
            $('#board .js-list').each(function (key, item) {
                item.classList.remove('hide');
            });
        } else {
            $('#board .js-list').each(function (key, item) {
                var subscribed = $(item).find('.list-header-extras .js-list-subscribed');
                if (subscribed.hasClass('hide')) {
                    item.classList.add('hide');
                }
            });
        }
    });

    // 打开时页面判断
    if (GM_getValue('subscribedStatus', false)) {
        GM_setValue('subscribedStatus', false);
        $('.board-header-btns .js-board-header-only-subscribed').click();
    }
})();