在Github和Deepwiki页面右下角添加互相跳转的浮动按钮

一个小小的快捷方式,带来大大的方便

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         在Github和Deepwiki页面右下角添加互相跳转的浮动按钮
// @namespace    https://greasyfork.org/zh-CN/scripts/535862-github-to-deepwiki-jump
// @version      2025.09.15
// @description  一个小小的快捷方式,带来大大的方便
// @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);
})();