Skip to content

Commit e5b7216

Browse files
committed
feat(github): 新脚本 GitHub 快速跳转到DeepWiKi
1 parent 9f976d7 commit e5b7216

6 files changed

Lines changed: 167 additions & 1 deletion

File tree

docs/ScriptsPath.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,19 @@
756756
"preview": "https://s2.loli.net/2025/04/21/vCNOWuMFUSRLGm5.png",
757757
"icon": "https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/github-commit-viewer.png",
758758
"locales": "zh-TW,vi,en,ko"
759+
},
760+
{
761+
"name": "",
762+
"description": "",
763+
"group": "GitHub相关脚本",
764+
"js_name": "github-to-deepwiki.user.js",
765+
"directory": "github-to-deepwiki",
766+
"version": "2025.5.17.1",
767+
"greasyfork_id": null,
768+
"created_at": "2025-05-17 17:37:19",
769+
"preview": "https://s2.loli.net/2025/05/17/VcHPTLnJ6Urf1dw.png",
770+
"icon": "https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/deepwiki.png",
771+
"locales": "zh-TW,vi,en,ko"
759772
}
760773
]
761774
}

github-to-deepwiki/AUTHORS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!---->
2+
<!--AUTHORS-->
3+
<!--AUTHORS-END-->
4+
<!--OTHERS-->
5+
[GitHub To DeepWiKi 1.0.1](https://chromewebstore.google.com/detail/mncphefajbojphfmfneoeojecehokplj)
6+
<!--OTHERS-END-->

github-to-deepwiki/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# **🛠️ github-to-deepwiki 更新日志**
2+
3+
### **📅 2025.5.17.1**
4+
**新增**: • 动态监听URL变化,自动插入DeepWiki按钮.支持桌面端和移动设备
5+
6+
---

github-to-deepwiki/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<a id="top"></a>
2+
<!--NAVIGATION-->
3+
<!--NAVIGATION-END-->
4+
<!--SHIELDS-->
5+
<!--SHIELDS-END-->
6+
<!--HISTORY-->
7+
<!--HISTORY-END-->
8+
<!--TEXT-->
9+
10+
11+
12+
<!--AUTHORS-->
13+
<!--AUTHORS-END-->
14+
<!--SCREENSHOT-->
15+
## 功能预览:
16+
17+
1. 桌面端:
18+
19+
![2025.05.17](https://s2.loli.net/2025/05/17/VcHPTLnJ6Urf1dw.png)
20+
21+
2. 移动端:
22+
![2025.05.17](https://s2.loli.net/2025/05/17/fzIRVdtU4uDH9Fi.png)
23+
24+
<!--SCREENSHOT-END-->
25+
<!--TEXT-END-->
26+
27+
<!--RELATED-->
28+
<!--RELATED-END-->
29+
<!--HELP-->
30+
<!--HELP-END-->
31+
<!--FOOTER-->
32+
33+
<img height="6px" width="100%" src="https://media.chatgptautorefresh.com/images/separators/gradient-aqua.png?latest">
34+
<center><div align="center"><p><a href="https://github.com/ChinaGodMan/UserScripts"><strong>更多用户脚本</strong></a> /<a href="#top">回到顶部↑</a></p></div></center>
35+
36+
<!--FOOTER--END-->
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// ==UserScript==
2+
// @name GitHub To DeepWiKi
3+
// @name:zh-CN GitHub 跳转到 DeepWiKi
4+
// @description GitHub to DeepWiKi.Supports desktop and mobile devices
5+
// @description:zh-CN GitHub 存储库跳转到 DeepWiKi,支持电脑桌面端和移动端
6+
// @author 人民的勤务员 <china.qinwuyuan@gmail.com>
7+
// @namespace https://github.com/ChinaGodMan/UserScripts
8+
// @supportURL https://github.com/ChinaGodMan/UserScripts/issues
9+
// @homepageURL https://github.com/ChinaGodMan/UserScripts
10+
// @license MIT
11+
// @match https://github.com/*
12+
// @icon https://raw.githubusercontent.com/ChinaGodMan/UserScriptsHistory/main/scriptsIcon/deepwiki.png
13+
// @compatible chrome
14+
// @compatible firefox
15+
// @compatible edge
16+
// @compatible opera
17+
// @compatible safari
18+
// @compatible kiwi
19+
// @compatible qq
20+
// @compatible via
21+
// @compatible brave
22+
// @version 2025.5.17.1
23+
// @downloadURL https://raw.githubusercontent.com/ChinaGodMan/UserScripts/main/github-to-deepwiki/github-to-deepwiki.user.js
24+
// @updateURL https://raw.githubusercontent.com/ChinaGodMan/UserScripts/main/github-to-deepwiki/github-to-deepwiki.user.js
25+
// ==/UserScript==
26+
27+
const DESKTOP_SELECTOR = '.mt-2'
28+
const MOBILE_SELECTOR = '#responsive-meta-container .d-flex.gap-2.mt-n3.mb-3.flex-wrap'
29+
const INITIAL_DELAY = 50
30+
const MAX_DELAY = 2000
31+
const MAX_ATTEMPTS = 15
32+
let checkTimer = null
33+
let currentDelay = INITIAL_DELAY
34+
let attemptCount = 0
35+
36+
function checkAndInsert() {
37+
if (checkTimer) {
38+
clearTimeout(checkTimer)
39+
checkTimer = null
40+
}
41+
42+
insertCustomElement(document.querySelector(MOBILE_SELECTOR), 'beforeend')
43+
const elements = document.querySelectorAll(DESKTOP_SELECTOR)
44+
if (elements.length >= 2) {
45+
const target = elements[elements.length - 2]
46+
if (insertCustomElement(target)) {
47+
console.log('插入成功,终止检测')
48+
return true
49+
}
50+
}
51+
52+
if (attemptCount >= MAX_ATTEMPTS) {
53+
console.warn(`已达到最大尝试次数 ${MAX_ATTEMPTS} 次`)
54+
return false
55+
}
56+
57+
currentDelay = Math.min(currentDelay * 1.5, MAX_DELAY)
58+
attemptCount++
59+
60+
checkTimer = setTimeout(() => {
61+
checkAndInsert()
62+
}, currentDelay)
63+
64+
return false
65+
}
66+
67+
function insertCustomElement(target) {
68+
if (!target?.parentNode) return false
69+
70+
try {
71+
const deepWikiSvg = '<svg height="16" width="16" data-view-component="true" class="octicon octicon-link flex-shrink-0 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="110 110 460 500"><path class="" d="M418.73,332.37c9.84-5.68,22.07-5.68,31.91,0l25.49,14.71c.82.48,1.69.8,2.58,1.06.19.06.37.11.55.16.87.21,1.76.34,2.65.35.04,0,.08.02.13.02.1,0,.19-.03.29-.04.83-.02,1.64-.13,2.45-.32.14-.03.28-.05.42-.09.87-.24,1.7-.59,2.5-1.03.08-.04.17-.06.25-.1l50.97-29.43c3.65-2.11,5.9-6.01,5.9-10.22v-58.86c0-4.22-2.25-8.11-5.9-10.22l-50.97-29.43c-3.65-2.11-8.15-2.11-11.81,0l-50.97,29.43c-.08.04-.13.11-.2.16-.78.48-1.51,1.02-2.15,1.66-.1.1-.18.21-.28.31-.57.6-1.08,1.26-1.51,1.97-.07.12-.15.22-.22.34-.44.77-.77,1.6-1.03,2.47-.05.19-.1.37-.14.56-.22.89-.37,1.81-.37,2.76v29.43c0,11.36-6.11,21.95-15.95,27.63-9.84,5.68-22.06,5.68-31.91,0l-25.49-14.71c-.82-.48-1.69-.8-2.57-1.06-.19-.06-.37-.11-.56-.16-.88-.21-1.76-.34-2.65-.34-.13,0-.26.02-.4.02-.84.02-1.66.13-2.47.32-.13.03-.27.05-.4.09-.87.24-1.71.6-2.51,1.04-.08.04-.16.06-.24.1l-50.97,29.43c-3.65,2.11-5.9,6.01-5.9,10.22v58.86c0,4.22,2.25,8.11,5.9,10.22l50.97,29.43c.08.04.17.06.24.1.8.44,1.64.79,2.5,1.03.14.04.28.06.42.09.81.19,1.62.3,2.45.32.1,0,.19.04.29.04.04,0,.08-.02.13-.02.89,0,1.77-.13,2.65-.35.19-.04.37-.1.56-.16.88-.26,1.75-.59,2.58-1.06l25.49-14.71c9.84-5.68,22.06-5.68,31.91,0,9.84,5.68,15.95,16.27,15.95,27.63v29.43c0,.95.15,1.87.37,2.76.05.19.09.37.14.56.25.86.59,1.69,1.03,2.47.07.12.15.22.22.34.43.71.94,1.37,1.51,1.97.1.1.18.21.28.31.65.63,1.37,1.18,2.15,1.66.07.04.13.11.2.16l50.97,29.43c1.83,1.05,3.86,1.58,5.9,1.58s4.08-.53,5.9-1.58l50.97-29.43c3.65-2.11,5.9-6.01,5.9-10.22v-58.86c0-4.22-2.25-8.11-5.9-10.22l-50.97-29.43c-.08-.04-.16-.06-.24-.1-.8-.44-1.64-.8-2.51-1.04-.13-.04-.26-.05-.39-.09-.82-.2-1.65-.31-2.49-.33-.13,0-.25-.02-.38-.02-.89,0-1.78.13-2.66.35-.18.04-.36.1-.54.15-.88.26-1.75.59-2.58,1.07l-25.49,14.72c-9.84,5.68-22.07,5.68-31.9,0-9.84-5.68-15.95-16.27-15.95-27.63s6.11-21.95,15.95-27.63Z" style="fill: rgb(33, 193, 154);"></path><path d="M141.09,317.65l50.97,29.43c1.83,1.05,3.86,1.58,5.9,1.58s4.08-.53,5.9-1.58l50.97-29.43c.08-.04.13-.11.2-.16.78-.48,1.51-1.02,2.15-1.66.1-.1.18-.21.28-.31.57-.6,1.08-1.26,1.51-1.97.07-.12.15-.22.22-.34.44-.77.77-1.6,1.03-2.47.05-.19.1-.37.14-.56.22-.89.37-1.81.37-2.76v-29.43c0-11.36,6.11-21.95,15.96-27.63s22.06-5.68,31.91,0l25.49,14.71c.82.48,1.69.8,2.57,1.06.19.06.37.11.56.16.87.21,1.76.34,2.64.35.04,0,.09.02.13.02.1,0,.19-.04.29-.04.83-.02,1.65-.13,2.45-.32.14-.03.28-.05.41-.09.87-.24,1.71-.6,2.51-1.04.08-.04.16-.06.24-.1l50.97-29.43c3.65-2.11,5.9-6.01,5.9-10.22v-58.86c0-4.22-2.25-8.11-5.9-10.22l-50.97-29.43c-3.65-2.11-8.15-2.11-11.81,0l-50.97,29.43c-.08.04-.13.11-.2.16-.78.48-1.51,1.02-2.15,1.66-.1.1-.18.21-.28.31-.57.6-1.08,1.26-1.51,1.97-.07.12-.15.22-.22.34-.44.77-.77,1.6-1.03,2.47-.05.19-.1.37-.14.56-.22.89-.37,1.81-.37,2.76v29.43c0,11.36-6.11,21.95-15.95,27.63-9.84,5.68-22.07,5.68-31.91,0l-25.49-14.71c-.82-.48-1.69-.8-2.58-1.06-.19-.06-.37-.11-.55-.16-.88-.21-1.76-.34-2.65-.35-.13,0-.26.02-.4.02-.83.02-1.66.13-2.47.32-.13.03-.27.05-.4.09-.87.24-1.71.6-2.51,1.04-.08.04-.16.06-.24.1l-50.97,29.43c-3.65,2.11-5.9,6.01-5.9,10.22v58.86c0,4.22,2.25,8.11,5.9,10.22Z" style="fill: rgb(57, 105, 202);"></path><path class="" d="M396.88,484.35l-50.97-29.43c-.08-.04-.17-.06-.24-.1-.8-.44-1.64-.79-2.51-1.03-.14-.04-.27-.06-.41-.09-.81-.19-1.64-.3-2.47-.32-.13,0-.26-.02-.39-.02-.89,0-1.78.13-2.66.35-.18.04-.36.1-.54.15-.88.26-1.76.59-2.58,1.07l-25.49,14.72c-9.84,5.68-22.06,5.68-31.9,0-9.84-5.68-15.96-16.27-15.96-27.63v-29.43c0-.95-.15-1.87-.37-2.76-.05-.19-.09-.37-.14-.56-.25-.86-.59-1.69-1.03-2.47-.07-.12-.15-.22-.22-.34-.43-.71-.94-1.37-1.51-1.97-.1-.1-.18-.21-.28-.31-.65-.63-1.37-1.18-2.15-1.66-.07-.04-.13-.11-.2-.16l-50.97-29.43c-3.65-2.11-8.15-2.11-11.81,0l-50.97,29.43c-3.65,2.11-5.9,6.01-5.9,10.22v58.86c0,4.22,2.25,8.11,5.9,10.22l50.97,29.43c.08.04.17.06.25.1.8.44,1.63.79,2.5,1.03.14.04.29.06.43.09.8.19,1.61.3,2.43.32.1,0,.2.04.3.04.04,0,.09-.02.13-.02.88,0,1.77-.13,2.64-.34.19-.04.37-.1.56-.16.88-.26,1.75-.59,2.57-1.06l25.49-14.71c9.84-5.68,22.06-5.68,31.91,0,9.84,5.68,15.95,16.27,15.95,27.63v29.43c0,.95.15,1.87.37,2.76.05.19.09.37.14.56.25.86.59,1.69,1.03,2.47.07.12.15.22.22.34.43.71.94,1.37,1.51,1.97.1.1.18.21.28.31.65.63,1.37,1.18,2.15,1.66.07.04.13.11.2.16l50.97,29.43c1.83,1.05,3.86,1.58,5.9,1.58s4.08-.53,5.9-1.58l50.97-29.43c3.65-2.11,5.9-6.01,5.9-10.22v-58.86c0-4.22-2.25-8.11-5.9-10.22Z" style="fill: rgb(2, 148, 222);"></path></svg>'
72+
const newDiv = document.createElement('div')
73+
let url = window.location.href.replace('github.com', 'deepwiki.com')
74+
newDiv.className = 'mt-2'
75+
newDiv.innerHTML = `
76+
<a href="${url}" target="_blank" class="Link Link--muted" id="myCustomLink">
77+
${deepWikiSvg}
78+
<strong style="color: #2583f1;">DeepWiki</strong>
79+
</a>
80+
`
81+
target.insertAdjacentElement('afterend', newDiv)
82+
return document.contains(newDiv)
83+
} catch (error) {
84+
console.error('插入失败:', error)
85+
return false
86+
}
87+
}
88+
89+
function observeUrlChanges(callback, delay = 10) {
90+
let lastUrl = location.href
91+
const observer = new MutationObserver(() => {
92+
const url = location.href
93+
if (url !== lastUrl) {
94+
lastUrl = url
95+
setTimeout(() => {
96+
callback()
97+
}, delay)
98+
}
99+
})
100+
observer.observe(document, { subtree: true, childList: true })
101+
return observer
102+
}
103+
observeUrlChanges(checkAndInsert)
104+
checkAndInsert()

utils/navigation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def main():
6262
md_new = get_md_files(script_directory) # 获取当前脚本目录下的所有过滤后的md文件
6363
all_in_old = all(md in set(md_old) for md in md_new) # 如果当前过滤后的readme文件名都md_old 不进行替换
6464
if all_in_old: # 哪怕导航栏模版发生变动,只要导航栏指向github的链接没变动就不进行替换
65-
continue
65+
print("链接在内容中存在")
66+
# continue
6667

6768
# 相等跳过
6869
if olddescriptions + "\n" == descriptions: # 换行符添加上,就这样了能用就行

0 commit comments

Comments
 (0)