GitHub 增强(显示 Fork 仓库与 Soure 仓库间差异的描述)

Compare Fork Repo With Source Repo

// ==UserScript==
// @name         GitHub 增强(显示 Fork 仓库与 Soure 仓库间差异的描述)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Compare Fork Repo With Source Repo
// @author       ko0r0sh, Liby
// @match        https://*.github.com/*
// @run-at       document-end
// @connect      *
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    if (/github\.com.+network\/members.*/.test(location.href)) {
        (function () {
            console.log("GitHub detected!");

            jQuery("div.repo > a:last-child").each(function(e){
                let repo = jQuery(this);
                let url = "https://github.com" + jQuery(this).attr("href");
                jQuery.get(url, function(data){
                    let info = /(This branch is[^\.]+\.)/.exec(data)[0];
                    let has_ahead = false;

                    let match_result = /(.+?)(\d+)( commits? ahead.+)/.exec(info);
                    if(match_result) {
                        info = match_result[1] + '<span style="background: #ebc944; color: #ffffff;">' + match_result[2] + '</span>' + match_result[3];
                        has_ahead = true;
                    }

                    repo.parent().append('<span style="margin-left: 20px;' + (has_ahead ? 'color: #ffffff; background: #1287a8; font-weight:bold;">' : '">')  + info + "</span>");
                })
            })
        })();
}
    // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址