一键获取github开源项目文档

一键获取github开源项目文档,让你快速熟悉开源项目。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         一键获取github开源项目文档
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  一键获取github开源项目文档,让你快速熟悉开源项目。
// @author       You
// @match        https://github.com/*/*
// @exclude      https://github.com/*/*/issues*
// @exclude      https://github.com/*/*/pull*
// @exclude      https://github.com/*/*/settings*
// @exclude      https://github.com/*/*/actions*
// @exclude      https://github.com/*/*/projects*
// @exclude      https://github.com/*/*/security*
// @exclude      https://github.com/*/*/pulse*
// @exclude      https://github.com/*/*/graphs*
// @exclude      https://github.com/*/*/wiki*
// @exclude      https://github.com/*/*/discussions*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 确保我们在项目主页上
    const pathParts = window.location.pathname.split('/').filter(part => part);
    if (pathParts.length !== 2) {
        return; // 不是项目主页,退出
    }

    // 查找匹配选择器的链接
    const repoLinks = document.querySelectorAll('#repo-title-component a');

    repoLinks.forEach(link => {
        // 移除color-fg-default属性
        link.classList.remove('color-fg-default');

        // 修改链接颜色为暖色调
        link.style.color = '#FF6B35'; // 橙色暖色调
        link.style.fontWeight = 'bold'; // 加粗显示

        // 获取原始href值
        const originalHref = link.getAttribute('href');

        // 添加前缀URL
        if (originalHref && !originalHref.includes('readmex.com')) {
            // 移除开头的斜杠(如果有)
            const cleanHref = originalHref.startsWith('/') ? originalHref.substring(1) : originalHref;
            // 设置新的href
            link.setAttribute('href', 'https://readmex.com/' + cleanHref);

            // 设置在新标签页中打开
            link.setAttribute('target', '_blank');

            // 添加提示信息
            link.setAttribute('title', '点击在ReadmeX中查看项目详细设计文档和功能文档');
        }
    });

    // 添加悬停效果
    const style = document.createElement('style');
    style.textContent = `
        #repo-title-component a:hover {
            text-decoration: underline;
            color: #FF8C61 !important;
            cursor: pointer;
        }

        #repo-title-component a::after {
            content: " 📄";
            font-size: 14px;
        }
    `;
    document.head.appendChild(style);
})();