Skip to content

Commit 80f79e8

Browse files
committed
新增 [标签页伪装为 Github(摸鱼)] 功能
1 parent 147d939 commit 80f79e8

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

V2ex-Enhanced.user.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name V2EX 增强
3-
// @version 1.0.3
3+
// @version 1.0.4
44
// @author X.I.U
5-
// @description 自动签到、自动无缝翻页、回到顶部(右键点击两侧空白处)
5+
// @description 自动签到、自动无缝翻页、回到顶部(右键点击两侧空白处)、标签页伪装为 Github(摸鱼)
66
// @match *://v2ex.com/*
77
// @match *://*.v2ex.com/*
88
// @icon https://www.v2ex.com/static/favicon.ico
@@ -23,7 +23,8 @@
2323
['menu_autoClockIn', '自动签到', '自动签到', true],
2424
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
2525
['menu_pageLoading_reply', '帖子内自动翻页', '帖子内自动翻页', false],
26-
['menu_backToTop', '回到顶部(右键点击两侧空白处)', '回到顶部', true]
26+
['menu_backToTop', '回到顶部(右键点击两侧空白处)', '回到顶部', true],
27+
['menu_fish', '标签页伪装为 Github(摸鱼)', '标签页伪装为 Github', false]
2728
], menu_ID = [];
2829
for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值
2930
if (GM_getValue(menu_ALL[i][0]) == null){GM_setValue(menu_ALL[i][0], menu_ALL[i][3])};
@@ -160,6 +161,7 @@
160161
}
161162

162163
curSite.pageUrl = ""; // 下一页URL
164+
if(menu_value('menu_fish'))fish() // 标签页伪装为 Github(摸鱼)
163165
if(menu_value('menu_autoClockIn'))setTimeout(qianDao, 1000) // 自动签到(后台),延迟 1 秒执行是为了兼容 [V2ex Plus] 扩展
164166
if(menu_value('menu_pageLoading'))pageLoading(); // 自动翻页(无缝)
165167
if(menu_value('menu_backToTop'))backToTop(); // 回到顶部(右键点击空白处)
@@ -204,6 +206,17 @@
204206
}
205207

206208

209+
// 标签页伪装为 Github(摸鱼)
210+
function fish() {
211+
window.document.title = 'GitHub'
212+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
213+
document.querySelector("link[rel*='shortcut icon']").href = 'https://github.githubassets.com/favicons/favicon-dark.png'
214+
} else {
215+
document.querySelector("link[rel*='shortcut icon']").href = 'https://github.githubassets.com/favicons/favicon.png'
216+
}
217+
}
218+
219+
207220
// 自动无缝翻页
208221
function pageLoading() {
209222
if (curSite.SiteTypeID > 0){

0 commit comments

Comments
 (0)