Trello Only see Subscribed

Add watch-only features to Trello kanbans

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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