Skip to content

Commit 636831a

Browse files
feat: github
1 parent fee179c commit 636831a

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/scripts-header/github.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = isProd =>
2+
`// ==UserScript==
3+
// @name GitHub 工具箱
4+
// @name:en GitHub ToolBox
5+
// @version 1.0.0
6+
// @description 添加用VS Code阅读代码按钮(github1s)
7+
// @description:en Read code with VS Code(github1s)
8+
// @author sakura-flutter
9+
// @namespace https://github.com/sakura-flutter/tampermonkey-scripts
10+
// @license MIT
11+
// @compatible chrome Latest
12+
// @compatible firefox Latest
13+
// @compatible edge Latest
14+
// @noframes
15+
// @grant window.onurlchange
16+
// @match https://github.com/*
17+
// ==/UserScript==
18+
`

src/scripts/github/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { $ } from '@/utils/selector'
2+
3+
function insert1sButton() {
4+
const actions = $('.pagehead-actions')
5+
if (actions == null || $('#github1s-button')) return
6+
7+
const btnHTML = '<li><a id="github1s-button" class="btn btn-sm" target="_blank">Github1s</a></li>'
8+
actions.insertAdjacentHTML('afterBegin', btnHTML)
9+
$('#github1s-button').onmouseenter = function() {
10+
const github1sURL = new URL(location)
11+
github1sURL.host = 'github1s.com'
12+
this.href = github1sURL.href
13+
}
14+
}
15+
16+
insert1sButton()
17+
window.addEventListener('urlchange', info => {
18+
setTimeout(insert1sButton, 200)
19+
})

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = (env, argv) => ({
2121
widescreen: './src/scripts/widescreen',
2222
redirect: './src/scripts/redirect',
2323
pixiv: './src/scripts/pixiv',
24+
github: './src/scripts/github',
2425
'view-ui': './src/scripts/view-ui',
2526
'element-ui': './src/scripts/element-ui',
2627
'mdn-web-docs': './src/scripts/mdn-web-docs',

0 commit comments

Comments
 (0)