// ==UserScript== // @name GitHub 增强Https复制 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 增强GitHub的复制HTTPS链接,附带加速链接 // @author tanyiqu // @match *://github.com/* // @grant none // @license GPL-3.0 License // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @downloadURL https://update.greasyfork.icu/scripts/419614/GitHub%20%E5%A2%9E%E5%BC%BAHttps%E5%A4%8D%E5%88%B6.user.js // @updateURL https://update.greasyfork.icu/scripts/419614/GitHub%20%E5%A2%9E%E5%BC%BAHttps%E5%A4%8D%E5%88%B6.meta.js // ==/UserScript== (function () { 'use strict'; /** * 生成显示信息为 value 的 html * @param {String} value value */ const generateHtml = (value) => { // v1.0 - v1.2 return `
` }; // 挂载 let mount = () => { let html = ''; // 获取第一个div let div = $("[role='tabpanel']").get(2); if (!div) { return; } // 获取第一个input-group标签 原封不动加在上面 let input_group = $(div).find('.input-group'); html += $(input_group).prop("outerHTML"); // 获取原链接地址 let url = input_group.find('input').val(); // https://github.com/xxx/yyyy.git // 截取后面的仓库名 let repository_name = url.replace(/http.*?github.com/,''); // 添加带有 “git clone” 的div html += generateHtml('git clone ' + url); // 添加加速链接 html += generateHtml('git clone https://hub.fastgit.org' + repository_name); html += generateHtml('git clone https://gitclone.com/github.com' + repository_name); html += generateHtml('git clone https://github.com.cnpmjs.org' + repository_name); // 链接下面的一行提示 html += `

Use Git or checkout with SVN using the web URL.

`; $(div).html(html); }; // 执行 mount(); })();