🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Github/Gitlab nav enhance

Added link button for quick jump to personal repository list in Github/Gitlab

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

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

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                Github/Gitlab nav enhance
// @name:zh-CN          Github/Gitlab 导航栏增强
// @description         Added link button for quick jump to personal repository list in Github/Gitlab
// @description:zh-CN   Github/Gitlab 导航增加快速跳转到个人仓库列表的链接按钮

// @author              GallenHu
// @namespace           https://hgl2.com
// @license             MIT
// @icon                https://github.githubassets.com/favicons/favicon.png

// @grant               none
// @run-at              document-end
// @include             *://github.com/*
// @include             *://gitlab.com/*

// @date                03/22/2021
// @modified            01/21/2022
// @version             0.2
// @require             https://cdn.staticfile.org/jquery/1.12.2/jquery.min.js
// ==/UserScript==


(function () {
    'use strict';

    const host = window.location.host;
    const pathname = window.location.pathname;
    const isGithub = host.endsWith('github.com');
    const isGitlab = host.endsWith('gitlab.com');

    if (isGithub) {
        const userName = document.querySelector('meta[name="user-login"]').content;

        const nav = document.querySelector('nav.d-flex');
        const html = `<a class="js-selected-navigation-item Header-link flex-auto mt-md-n3 mb-md-n3 py-2 py-md-3 mr-0 mr-md-3 border-top border-md-top-0 border-white-fade-15" data-ga-click="Header, click, Nav menu - item:marketplace context:user" data-octo-click="marketplace_click" data-octo-dimensions="location:nav_bar" data-selected-links="/${userName}?tab=repositories" href="/${userName}?tab=repositories">Repositories</a>
        <a class="js-selected-navigation-item Header-link flex-auto mt-md-n3 mb-md-n3 py-2 py-md-3 mr-0 mr-md-3 border-top border-md-top-0 border-white-fade-15" data-ga-click="Header, click, Nav menu - item:marketplace context:user" data-octo-click="marketplace_click" data-octo-dimensions="location:nav_bar" data-selected-links="/${userName}?tab=repositories" href="/${userName}?tab=stars">Stars</a>
       `
        $(nav).append(html);
    }

    if (isGitlab) {
        const userName = window.gon.current_username;
        const nav = document.querySelector('ul.navbar-sub-nav');
        const html = `<ul class="nav navbar-sub-nav">
        <li class="nav-item">
            <a href="/">Repositories</a>
        </li>
        <li class="nav-item">
            <a href="/users/${userName}/starred">Stars</a>
        </li>
        </ul>
        `
        $(document).ready(() => {
            $('.title-container').append(html);
        });

    }
})();