├── asset └── preview.png ├── README.md └── tampermonkey-script.js /asset/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/go-deepwiki/HEAD/asset/preview.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # go-deepwiki 2 | 3 | github 跳转 deepwiki 的油猴脚本 4 | 5 | ## 安装 6 | 7 | 1. 安装[tampermonkey](https://chromewebstore.google.com/detail/%E7%AF%A1%E6%94%B9%E7%8C%B4/dhdgffkkebhmkfjojejmpbldmpobfkfo)浏览器插件 8 | 9 | 2. 安装脚本[greasyfork](https://greasyfork.org/zh-CN/scripts/534059-github-go-deepwiki) 10 | 11 | ### 另一种方式 12 | 13 | 不想装tampermonkey的用户,也可以试试这个chrome插件: 14 | 15 | - chorme插件地址: [github-deepwiki](https://chromewebstore.google.com/detail/github-deepwiki-unofficia/agchcjkheangfiopepndmenabbaopnpp) 16 | - 插件的开源地址: [github-deepwiki](https://github.com/yamadashy/github-deepwiki) 17 | 18 | ## 预览 19 | 20 | ![preview](./asset/preview.png) 21 | -------------------------------------------------------------------------------- /tampermonkey-script.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name github-go-deepwiki 3 | // @namespace 4 | // @version 0.3 5 | // @description github仓库跳转到deepwiki 6 | // @source https://github.com/gxr404/go-deepwiki 7 | // @author gxr404 8 | // @match https://github.com/* 9 | // @grant none 10 | // ==/UserScript== 11 | (function() { 12 | 'use strict'; 13 | 14 | const bodyEl = document.querySelector('body') 15 | if (bodyEl) { 16 | watchDom(bodyEl, main) 17 | main() 18 | } 19 | })(); 20 | 21 | function watchDom(dom, callback) { 22 | const observer = new MutationObserver(() => { 23 | callback() 24 | }) 25 | observer.observe(dom, { 26 | childList: true, 27 | subtree: true, 28 | }) 29 | } 30 | 31 | function main() { 32 | // match https://github.com// 33 | if (location.pathname.split('/').filter(Boolean).length !== 2) return 34 | if (document.getElementById('go-deepwiki')) return 35 | const repoBtnContainer = document.getElementById('repository-details-container') 36 | if (!repoBtnContainer) return 37 | const btnList = repoBtnContainer.querySelector('ul') 38 | if (!btnList) return 39 | btnList.appendChild(createGoDeepWikiDOM()) 40 | } 41 | 42 | function createGoDeepWikiDOM() { 43 | const li = document.createElement('li') 44 | const repName = location.pathname.split('/').filter(Boolean).slice(0,2).join('/') 45 | const deepWikiUrl = `https://deepwiki.com/${repName}` 46 | li.innerHTML = ` 47 |
  • 48 | 57 |
  • 58 | ` 59 | return li 60 | } 61 | --------------------------------------------------------------------------------