Github to Deepwiki Jump

在Github和Deepwiki页面之间添加互相跳转的浮动按钮

// ==UserScript==
// @name         Github to Deepwiki Jump
// @namespace    https://greasyforks.org/zh-CN/scripts/535862-github-to-deepwiki-jump
// @version      0.3
// @description  在Github和Deepwiki页面之间添加互相跳转的浮动按钮
// @license      MIT
// @match        https://github.com/*
// @match        https://deepwiki.com/*
// @icon         https://github.githubassets.com/favicons/favicon.png
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // 创建浮动按钮
    function createFloatingButton() {
        const path = window.location.pathname;
        const button = document.createElement('a');
        
        // 设置按钮样式
        button.style.position = 'fixed';
        button.style.right = '20px';
        button.style.bottom = '20px';
        button.style.backgroundColor = '#2b3137';
        button.style.color = 'white';
        button.style.padding = '10px 15px';
        button.style.borderRadius = '5px';
        button.style.textDecoration = 'none';
        button.style.fontFamily = 'Arial, sans-serif';
        button.style.fontWeight = 'bold';
        button.style.zIndex = '9999';
        button.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
        
        // 根据当前域名设置不同的按钮文本和链接
        if (window.location.hostname === 'deepwiki.com') {
            button.textContent = '返回GitHub';
            button.href = `https://github.com${path}`;
        } else {
            button.textContent = '跳转Deepwiki';
            button.href = `https://deepwiki.com${path}`;
        }
        
        button.target = '_blank';
        
        // 添加悬停效果
        button.addEventListener('mouseover', () => {
            button.style.backgroundColor = '#3f4a56';
        });
        button.addEventListener('mouseout', () => {
            button.style.backgroundColor = '#2b3137';
        });
        
        // 添加到页面
        document.body.appendChild(button);
    }

    // 页面加载完成后创建按钮
    window.addEventListener('load', createFloatingButton);
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。