Greasy Fork

Greasy Fork is available in English.

teambition隐藏非自己的card

try to take over the world!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         teambition隐藏非自己的card
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       You
// @match        https://www.teambition.com/project/*/sprint/section/*
// @grant        none
// ==/UserScript==

window.onload = function(){setInterval(register_myfuncs, 8000)}

var myprofile
var paths = window.location.pathname.split("/")
var project_id = paths[2]
var sprint = paths[5]
var users_url = "https://www.teambition.com/api/searchers/options?q=&_projectId=" + project_id + "&id=executorId&pageToken=&pageSize=1"

function register_myfuncs(){
    if (!(window.location.href.includes("https://www.teambition.com/project/") && window.location.href.includes("/sprint/section/"))) {
        return
    }
    if (document.getElementById("myhidebtn")) {
        if (document.getElementById("myhidebtn").innerText == "显示") {
            var cards = document.getElementsByClassName("kanban-dnd-card")
            for (var card of cards) {
                var head = card.getElementsByClassName("avatar__1gRA")
                var name
                if (head.length == 0) name = ""
                else name = card.getElementsByClassName("avatar__1gRA")[0].attributes["data-title"].value
                if (name != myprofile.name) {
                    card.style.display = "none"
                }
            }
        }
        return
    }

    console.log("start register")

    fetch(users_url).then(function(response) {
        return response.json();
    }).then(function(myJson) {
        myprofile = myJson.result[0]
    })

    var btn = document.createElement("button")
    btn.id = "myhidebtn"
    btn.innerText = "隐藏"
    btn.onclick = function () {
        var cards = document.getElementsByClassName("kanban-dnd-card")
        var other_cards = []
        for (var card of cards) {
            var head = card.getElementsByClassName("avatar__1gRA")
            var name
            if (head.length == 0) name = ""
            else name = card.getElementsByClassName("avatar__1gRA")[0].attributes["data-title"].value
            if (name != myprofile.name) {
                other_cards.push(card)
            }
        }

        function hidden_not_mine() {
            for (var card of other_cards) {
                card.style.display = "none"
            }
        }
        function show_not_mine() {
            for (var card of other_cards) {
                card.style.display = ""
            }
        }
        if (btn.innerText == "隐藏") {
            btn.innerText = "显示"
            hidden_not_mine()
        } else {
            btn.innerText = "隐藏"
            show_not_mine()
        }
    }
    document.getElementsByClassName('board-view-top-mode__20ny')[0].getElementsByTagName('div')[0].appendChild(btn)

    console.log("end register")
}