GreasyFork: Побољшање траке за навигацију

Додајте листу корисника на траку за навигацију,конзола,Збирка итд...

// ==UserScript==
// @name              GreasyFork: User Control Panel Button
// @name:zh-CN        GreasyFork: 导航栏增强
// @description:zh-CN 在导航栏上添加用户列表,控制台,收藏等..
// @name:ar           GreasyFork: تعزيز شريط التنقل
// @description:ar    إضافة قائمة المستخدمين على شريط التنقل,وحدة التحكم,جمع الخ..
// @name:bg           GreasyFork: Подобряване на лентата за навигация
// @description:bg    Добавяне на потребителски списък в лентата за навигация,конзола,Колекция и др...
// @name:cs           GreasyFork: Vylepšení navigační lišty
// @description:cs    Přidejte seznam uživatelů na navigační lištu,utěšit,Sbírka atd...
// @name:da           GreasyFork: Forbedring af navigationslinjen
// @description:da    Tilføj brugerliste på navigationslinjen,konsol,Indsamling mv...
// @name:de           GreasyFork: Verbesserung der Navigationsleiste
// @description:de    Benutzerliste zur Navigationsleiste hinzufügen,Konsole,Sammlung usw...
// @name:el           GreasyFork: Βελτίωση της γραμμής πλοήγησης
// @description:el    Προσθήκη λίστας χρηστών στη γραμμή πλοήγησης,κονσόλα,Συλλογή κλπ...
// @name:en           GreasyFork: Navigation bar enhancement
// @description:en    Add user list on navigation bar,console,Collection etc...
// @name:eo           GreasyFork: Plibonigo de navigado trinkejo
// @description:eo    Aldonu uzantliston sur navigadbreto,konzolo,Kolekto ktp...
// @name:es           GreasyFork: Mejora de la barra de navegación
// @description:es    Agregar lista de usuarios en la barra de navegación,consola,Colección, etc...
// @name:fi           GreasyFork: Navigointipalkin parannus
// @description:fi    Lisää käyttäjäluettelo navigointipalkkiin,konsoli,Kokoelma jne...
// @name:fr           GreasyFork: Amélioration de la barre de navigation
// @description:fr    Ajouter une liste d’utilisateurs sur la barre de navigation,console,Collecte etc..
// @name:he           GreasyFork: שיפור סרגל הניווט
// @description:he    הוסף רשימת משתמשים בסרגל הניווט,לְנַחֵם,אוסף וכו’...
// @name:hr           GreasyFork: Poboljšanje navigacijske trake
// @description:hr    Dodajte popis korisnika na navigacijsku traku,konzola,Zbirka itd...
// @name:hu           GreasyFork: A navigációs sáv továbbfejlesztése
// @description:hu    Felhasználói lista hozzáadása a navigációs sávhoz,konzol,Gyűjtemény stb...
// @name:id           GreasyFork: Peningkatan bilah navigasi
// @description:id    Tambahkan daftar pengguna di bilah navigasi,menghibur,Koleksi dll...
// @name:it           GreasyFork: Miglioramento della barra di navigazione
// @description:it    Aggiungi l’elenco degli utenti sulla barra di navigazione,consolle,Raccolta ecc...
// @name:ja           GreasyFork: ナビゲーションバーの強化
// @description:ja    ナビゲーションバーにユーザーリストを追加,コンソール,コレクションなど..
// @name:ka           GreasyFork: ნავიგაციის ზოლის გაუმჯობესება
// @description:ka    დაამატეთ მომხმარებლის სია ნავიგაციის ზოლში,კონსოლი,კოლექცია და ა.შ...
// @name:ko           GreasyFork: 탐색 표시줄 개선
// @description:ko    탐색 표시줄에 사용자 목록 추가,콘솔,수집 등..
// @name:nl           GreasyFork: Verbetering van de navigatiebalk
// @description:nl    Voeg een gebruikerslijst toe aan de navigatiebalk,troosten,Collectie enz...
// @name:nb           GreasyFork: Forbedring av navigasjonslinjen
// @description:nb    Legg til brukerliste på navigasjonslinjen,konsoll,Samling etc...
// @name:pl           GreasyFork: Udoskonalenie paska nawigacji
// @description:pl    Dodaj listę użytkowników na pasku nawigacyjnym,konsola,Kolekcja itp...
// @name:pt-BR        GreasyFork: Aprimoramento da barra de navegação
// @description:pt-BR Adicionar lista de usuários na barra de navegação,console,Coleção etc..
// @name:ro           GreasyFork: Îmbunătățirea barei de navigare
// @description:ro    Adăugați lista de utilizatori pe bara de navigare,consolă,Colectare etc...
// @name:ru           GreasyFork: Улучшение панели навигации
// @description:ru    Добавить список пользователей на панель навигации,консоль,Коллекция и т. д...
// @name:sk           GreasyFork: Vylepšenie navigačnej lišty
// @description:sk    Pridajte zoznam používateľov na navigačnú lištu,konzoly,Zbierka atď...
// @name:sr           GreasyFork: Побољшање траке за навигацију
// @description:sr    Додајте листу корисника на траку за навигацију,конзола,Збирка итд...
// @name:sv           GreasyFork: Förbättring av navigeringsfältet
// @description:sv    Lägg till användarlista i navigeringsfältet,trösta,Samling etc...
// @name:th           GreasyFork: การเพิ่มประสิทธิภาพแถบนำทาง
// @description:th    เพิ่มรายชื่อผู้ใช้บนแถบนำทาง,คอนโซล,คอลเลกชัน ฯลฯ..
// @name:tr           GreasyFork: Gezinme çubuğu geliştirmesi
// @description:tr    Gezinme çubuğuna kullanıcı listesi ekleyin,konsol,Koleksiyon vb...
// @name:ug           GreasyFork: يولباشچى بالداقنى كۈچەيتىش
// @description:ug    يولباشچى ستونىغا ئىشلەتكۈچى تىزىملىكىنى قوشۇڭ,console,توپلاش قاتارلىقلار...
// @name:uk           GreasyFork: Покращення панелі навігації
// @description:uk    Додати список користувачів на панель навігації,консоль,Колекція тощо..
// @name:vi           GreasyFork: Cải tiến thanh điều hướng
// @description:vi    Thêm danh sách người dùng trên thanh điều hướng,bảng điều khiển,Bộ sưu tập vv...
// @name:zh-TW        GreasyFork: 導覽列增強
// @description:zh-TW 在導覽列上新增使用者列表,主機,收藏等..
// @name:zh-HK        GreasyFork: 導覽列增強
// @description:zh-HK 在導覽列上新增使用者列表,主機,收藏等..
// @name:fr-CA        GreasyFork: Amélioration de la barre de navigation
// @description:fr-CA Ajouter une liste d’utilisateurs sur la barre de navigation,console,Collecte etc..
// @namespace         https://github.com/ChinaGodMan/UserScripts
// @match             https://greasyfork.org/*
// @match             https://sleazyfork.org/*
// @grant             none
// @version           0.3.1.57
// @license           MIT
// @author            CY Fung & 人民的勤务员 <china.qinwuyuan@gmail.com>
// @description       To add User Control Panel Button into navigation bar
// @icon              data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gYRBAceMUIR3QAAEg9JREFUeNrtXWlwVNW2/k4n3RkbM5FRMEHUBOIAekGMJV4lYVDBAeQ+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IDAyvFOgfjJpIkAK8mJSX9OyMjw6BUKrlx40ZqNBrqdDoeOHCAd9xxh4VyZs2axR9//JFXr151GHkgiauTMKQIhWvXrlGj0fCjjz5iSEgIy8rKpMiOdqVS+a0YOpKEm1QEceQ8DsD2sLAw3YIFC1hSUkKtVsuamhrZPWxvsZ515AHcPAlDilAwGo1sa2tjY2Mjd+3axbS0NAYGBraK4YLjxLoJuIUkAcByQRCOp6WlXVm4cKFh6tSpnDhxIquqqlhVVcXp06czOjqawcHBNpEHcHFyxalTp+Rls/v27eOKFSsYExOjFwThN1wPEV8OJ4Gyt5IocX3BQk5QUNB/x8bGfpeenv6rWq226TOSkpJ44cIFedOPzs5OajQai4OXBw0axGXLlnHChAkE0J6cnHw+Ojr6W1xfFpQjlqXyF0pwKUajMUAQBMV1n5Zg4ehSKBRd4u8q0enVZcchppKudXXdli1bAvfs2aP+448/wvV6fbhOp7uzq6srzWg03knyDpIxJCMBRHR1dYWpVCoA0Hd1dV0FcBWABsDF8PDwOpVKVaXVan8ZOXJkZ1xcXNvhw4ebxZGsRZlSfUwmk0oQBLS3t3eLwVTuOPvsvo+z9zSX/wfl+jWwZp8+ogAAAABJRU5ErkJggg==
// @iconbak           https://greasyfork.org/vite/assets/blacklogo96-CxYTSM_T.png
// @supportURL        https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL       https://github.com/ChinaGodMan/UserScripts
// ==/UserScript==

(async () => {
    let sections = [
        { id: '#user-script-sets-section' },
        { id: '#control-panel' },
        // { id: '#user-library-list-section', name: '库' },
        //{ id: '#user-unlisted-script-list-section', name: '没上架' },
        //  { id: '#user-discussions', name: '讨论' },
        { id: '#user-script-list-section' }
    ]

    function preSetup() {
        let pos = document.querySelectorAll('#site-nav>nav>li.with-submenu')
        pos = pos.length >= 1 ? pos[pos.length - 1] : null

        if (!pos) return

        pos.parentNode.style.minHeight = '2.8rem'

        return { pos }
    }

    function setup(m, namespace) {
        const { cpmRoot } = m

        let h = cpmRoot.querySelector('h3') || cpmRoot.querySelector('header')
        if (!h) return

        let nav = document.createElement('nav')

        let addedText = new Set()
        let lastText = null

        for (const anchor of cpmRoot.querySelectorAll('li a[href]')) {
            let textContent = anchor.textContent.trim()

            if (addedText.has(textContent)) {
                lastText = textContent
                continue
            }

            let li = nav.appendChild(document.createElement('li'))
            li.appendChild(anchor)

            addedText.add(textContent)
        }

        if (lastText !== null) {
            nav.querySelectorAll('li').forEach(li => {
                if (li.querySelector('a').textContent.trim() === lastText) {
                    li.remove()
                }
            })
        }

        let tm = document.createElement('template')
        tm.innerHTML = `
        <li class="with-submenu" style="display: block;">
            <a href="#" onclick="return false">${namespace ? namespace : h.textContent}</a>
            <nav style="min-width: initial;">
                ${nav.innerHTML}
            </nav>
        </li>
    `.trim()

        return tm.content
    }

    function bufferToHex(buffer) {
        const byteArray = new Uint8Array(buffer)
        const len = byteArray.length
        const hexCodes = new Array(len * 2)
        const chars = '0123456789abcdef'
        for (let i = 0, j = 0; i < len; i++) {
            const byte = byteArray[i]
            hexCodes[j++] = chars[byte >> 4]
            hexCodes[j++] = chars[byte & 0x0F]
        }
        return hexCodes.join('')
    }

    async function digestMessage(message) {
        const encoder = new TextEncoder('utf-8')
        const msgUint8 = encoder.encode(message)
        const hashBuffer = await crypto.subtle.digest('SHA-1', msgUint8)
        return bufferToHex(hashBuffer)
    }

    async function fetchHTML(href) {
        let response = await fetch(href, {
            method: 'GET',
            mode: 'same-origin',
            cache: 'force-cache',
            credentials: 'same-origin',
            redirect: 'follow',
            referrerPolicy: 'no-referrer'
        })

        return response.text()
    }

    async function addSectionsToNav() {
        let presetup = preSetup()
        if (!presetup) return
        const { pos } = presetup

        let plink = document.querySelector('.user-profile-link')
        if (!plink) return
        let href = plink.querySelector('a[href*="/users/"]').href
        if (href.includes('/users/sign')) return

        let dm = await digestMessage(href)
        const stKey = `gf_user_page_${dm}`

        for (let trialN = 8; trialN--;) {
            let s = sessionStorage.getItem(stKey)
            let d = typeof s === 'string' ? parseInt(s) : 0
            if (d > 9 && Date.now() - d < 8000) await new Promise(r => setTimeout(r, 320))
            else break
        }

        const userPageHTML = await fetchHTML(href)
        if (!userPageHTML || typeof userPageHTML !== 'string') return

        sessionStorage.setItem(stKey, userPageHTML)

        let template = document.createElement('template')
        template.innerHTML = userPageHTML
        const content = template.content



        sections.forEach(({ id, name }) => {
            let section = content.querySelector(id)
            if (section) {
                const kc = setup({ cpmRoot: section, pos }, name)
                if (kc) {
                    pos.parentNode.insertBefore(kc, pos.nextSibling)
                }
            }
        })
    }

    if (!document.querySelector('.sign-out-link') || document.querySelector('.sign-in-link')) return

    await addSectionsToNav()
})()