GitHub Your Fork

Shows a 'your fork is at' link below the title

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        GitHub Your Fork
// @icon        https://github.com/eXistenZNL/userscripts/raw/master/icons/github.png
// @namespace   eXistenZNL
// @description Shows a 'your fork is at' link below the title
// @include     https://*github.com/*
// @version     1.0.5
// @grant       none
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js
// ==/UserScript==

(function($) {
    if (0 === $('h1.entry-title').length) {
        console.warn('No header found with class "entry-title"');
        return;
    }
    if (0 !== $('h1.fork-flag').length) {
        console.warn('Already have a fork');
        return;
    }
    var username = String.trim($('a.name').attr('href')).substring(1);
    var repository = $('h1 strong a').html();
    var url = '/' + username + '/' + repository;
    $.get(
        url,
        function () {
            $('.entry-title').append('<span class="fork-flag"><span class="text">your fork is at <a href="' + url + '">' + username + '/' + repository + '</a></span></span>');
        }
    ).fail(function() {
       $('.entry-title').append('<span class="fork-flag"><span class="text">You dont have a fork (yet!)</span></span>');
    });
})(jQuery);