remove Top repositories

去除Top repositories中不属于自己的仓库

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

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

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         remove Top repositories
// @version      1.0.0
// @namespace    https://github.com/girl-dream
// @description  去除Top repositories中不属于自己的仓库
// @author       girl-dream
// @license      The Unlicense
// @match        https://github.com/
// @icon         https://github.com/favicon.ico
// @grant        none
// ==/UserScript==


(function () {
    'use strict'
    let RepositoriesDom = document.querySelector('.dashboard-sidebar')
    let userName = RepositoriesDom.querySelector('.Button-label').lastChild.textContent
    if (!userName) return

    function run(ul) {
        for (let i = ul.length - 1; i >= 0; i--) {
            if (!ul[i].getElementsByTagName("a")[1].textContent.includes(userName)) {
                ul[i].remove()
            }
        }
    }
    let timer = setInterval(() => {
        let ul = RepositoriesDom.querySelector('.list-style-none').children
        if (ul.length > 0) {
            clearInterval(timer)
            run(ul)

            let temp = ul.length
            let a = RepositoriesDom.querySelector('.js-repos-container').getElementsByTagName("button")[0]
            a.addEventListener("click", () => {
                let timer = setInterval(() => {
                    let ul = RepositoriesDom.querySelector('.list-style-none').children
                    if (ul.length > temp) {
                        clearInterval(timer)
                        run(ul)
                    }
                })
            })
        }
    }, 500)
})();