More Nav on Github

add more items on navbar

目前為 2017-11-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name More Nav on Github
// @namespace https://github.com/delta4d
// @version 0.0.1
// @license MIT License
// @match https://github.com/*
// @run-at document-end
// @grant none
// @description add more items on navbar
// ==/UserScript==

// jshint esversion: 6

'use strict';

var addNavItem = (() => {
    const nav = document.querySelector('[role="navigation"]');
    const cls = nav.firstElementChild.firstElementChild.className; // ul > li > a

    return (desc, addr) => {
        let a = document.createElement("a");
        a.setAttribute("class", cls);
        a.setAttribute("href", addr);
        a.innerText = desc;

        let item = document.createElement("li");
        item.appendChild(a);
        
        nav.appendChild(item);
    };
})();

addNavItem("Stars", "/stars");
addNavItem("Settings", "/settings");