gistfile1.txt
· 2.3 KiB · Text
原始檔案
// ==UserScript==
// @name 在Github和Deepwiki页面右下角添加互相跳转的浮动按钮
// @namespace https://greasyfork.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
// @downloadURL https://update.greasyfork.org/scripts/535862/Github%20to%20Deepwiki%20Jump.user.js
// @updateURL https://update.greasyfork.org/scripts/535862/Github%20to%20Deepwiki%20Jump.meta.js
// ==/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);
})();
| 1 | // ==UserScript== |
| 2 | // @name 在Github和Deepwiki页面右下角添加互相跳转的浮动按钮 |
| 3 | // @namespace https://greasyfork.org/zh-CN/scripts/535862-github-to-deepwiki-jump |
| 4 | // @version 0.3 |
| 5 | // @description 在Github和Deepwiki页面右下角添加互相跳转的浮动按钮 |
| 6 | // @license MIT |
| 7 | // @match https://github.com/* |
| 8 | // @match https://deepwiki.com/* |
| 9 | // @icon https://github.githubassets.com/favicons/favicon.png |
| 10 | // @grant none |
| 11 | // @run-at document-end |
| 12 | // @downloadURL https://update.greasyfork.org/scripts/535862/Github%20to%20Deepwiki%20Jump.user.js |
| 13 | // @updateURL https://update.greasyfork.org/scripts/535862/Github%20to%20Deepwiki%20Jump.meta.js |
| 14 | // ==/UserScript== |
| 15 | |
| 16 | (function() { |
| 17 | 'use strict'; |
| 18 | |
| 19 | // 创建浮动按钮 |
| 20 | function createFloatingButton() { |
| 21 | const path = window.location.pathname; |
| 22 | const button = document.createElement('a'); |
| 23 | |
| 24 | // 设置按钮样式 |
| 25 | button.style.position = 'fixed'; |
| 26 | button.style.right = '20px'; |
| 27 | button.style.bottom = '20px'; |
| 28 | button.style.backgroundColor = '#2b3137'; |
| 29 | button.style.color = 'white'; |
| 30 | button.style.padding = '10px 15px'; |
| 31 | button.style.borderRadius = '5px'; |
| 32 | button.style.textDecoration = 'none'; |
| 33 | button.style.fontFamily = 'Arial, sans-serif'; |
| 34 | button.style.fontWeight = 'bold'; |
| 35 | button.style.zIndex = '9999'; |
| 36 | button.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)'; |
| 37 | |
| 38 | // 根据当前域名设置不同的按钮文本和链接 |
| 39 | if (window.location.hostname === 'deepwiki.com') { |
| 40 | button.textContent = '返回GitHub'; |
| 41 | button.href = `https://github.com${path}`; |
| 42 | } else { |
| 43 | button.textContent = '跳转Deepwiki'; |
| 44 | button.href = `https://deepwiki.com${path}`; |
| 45 | } |
| 46 | |
| 47 | button.target = '_blank'; |
| 48 | |
| 49 | // 添加悬停效果 |
| 50 | button.addEventListener('mouseover', () => { |
| 51 | button.style.backgroundColor = '#3f4a56'; |
| 52 | }); |
| 53 | button.addEventListener('mouseout', () => { |
| 54 | button.style.backgroundColor = '#2b3137'; |
| 55 | }); |
| 56 | |
| 57 | // 添加到页面 |
| 58 | document.body.appendChild(button); |
| 59 | } |
| 60 | |
| 61 | // 页面加载完成后创建按钮 |
| 62 | window.addEventListener('load', createFloatingButton); |
| 63 | })(); |