Github to Deepwiki Jump

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

  1. // ==UserScript==
  2. // @name Github to Deepwiki Jump
  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. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // 创建浮动按钮
  18. function createFloatingButton() {
  19. const path = window.location.pathname;
  20. const button = document.createElement('a');
  21. // 设置按钮样式
  22. button.style.position = 'fixed';
  23. button.style.right = '20px';
  24. button.style.bottom = '20px';
  25. button.style.backgroundColor = '#2b3137';
  26. button.style.color = 'white';
  27. button.style.padding = '10px 15px';
  28. button.style.borderRadius = '5px';
  29. button.style.textDecoration = 'none';
  30. button.style.fontFamily = 'Arial, sans-serif';
  31. button.style.fontWeight = 'bold';
  32. button.style.zIndex = '9999';
  33. button.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
  34. // 根据当前域名设置不同的按钮文本和链接
  35. if (window.location.hostname === 'deepwiki.com') {
  36. button.textContent = '返回GitHub';
  37. button.href = `https://github.com${path}`;
  38. } else {
  39. button.textContent = '跳转Deepwiki';
  40. button.href = `https://deepwiki.com${path}`;
  41. }
  42. button.target = '_blank';
  43. // 添加悬停效果
  44. button.addEventListener('mouseover', () => {
  45. button.style.backgroundColor = '#3f4a56';
  46. });
  47. button.addEventListener('mouseout', () => {
  48. button.style.backgroundColor = '#2b3137';
  49. });
  50. // 添加到页面
  51. document.body.appendChild(button);
  52. }
  53.  
  54. // 页面加载完成后创建按钮
  55. window.addEventListener('load', createFloatingButton);
  56. })();