-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzhihu_dark_mode.js
More file actions
30 lines (27 loc) · 848 Bytes
/
zhihu_dark_mode.js
File metadata and controls
30 lines (27 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ==UserScript==
// @name 知乎黑暗模式
// @version 0.1
// @namespace https://github.com/fwqaaq/scripts
// @author fwqaaq
// @icon https://static.zhihu.com/heifetz/assets/apple-touch-icon-120.d5793cac.png
// @description 知乎黑暗模式(原生)
// @match *://*.zhihu.com/*
// @run-at document-start
// ==/UserScript==
function main() {
const url = window.location.href
if (url.includes('www.zhihu.com/signin')) {
window.location.href = 'https://www.zhihu.com/explore?theme=dark'
return
}
if (url.includes('?')) {
if (!url.includes('theme=dark')) window.location.href += '&theme=dark'
} else {
window.location.href += '?theme=dark'
}
}
window.addEventListener('load', (e) => {
const btn = document.querySelector("button[aria-label='关闭']")
btn.click()
})
main()