├── .eslintrc.yml
├── README.md
├── android
└── bilibili.user.js
├── aqistudy.user.js
├── arch-packages.user.js
├── bilibili.user.js
├── chito.user.js
├── cks.user.js
├── docsrs.user.js
├── duolingo.user.js
├── element.user.js
├── github-tweak.user.js
├── gitlab-tweak.user.js
├── gitlab.user.js
├── google_cache_redirect.user.js
├── google_searchbar.user.js
├── googlegroups_remove_translation_tip.user.js
├── ipip-tweak.user.js
├── mp.weixin.user.js
├── readthedocs.user.js
├── taobao.user.js
├── telegram-web.user.js
├── visited-links.user.js
├── wikipedia-lang-reorder.user.js
├── youtube-cc-lang.user.js
├── youtube-space.user.js
├── zdic.user.js
└── zhihu-tweak.user.js
/.eslintrc.yml:
--------------------------------------------------------------------------------
1 | env:
2 | es6: true
3 | browser: true
4 | extends: 'eslint:recommended'
5 | rules:
6 | indent:
7 | - off
8 | linebreak-style:
9 | - error
10 | - unix
11 | quotes:
12 | - error
13 | - single
14 | semi:
15 | - error
16 | - never
17 | no-console:
18 | - off
19 | no-unused-vars:
20 | - warn
21 | - varsIgnorePattern: ^_
22 | argsIgnorePattern: ^_
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | My various Tampermonkey / GreaseMonkey scripts
2 |
3 | github-tweak
4 | ===
5 | * use gzip format for downloading
6 | * use ssh protocol for initialization instructions
7 |
8 | [Install](https://github.com/lilydjwg/userscripts/raw/master/github-tweak.user.js)
9 |
10 | gitlab-tweak
11 | ===
12 | * move notification button / status out to sidebar
13 |
14 | [Install](https://github.com/lilydjwg/userscripts/raw/master/gitlab-tweak.user.js)
15 |
16 | docsrs
17 | ===
18 | * use `/latest/` version links for search results
19 | * show visited search results in a different color
20 |
21 | [Install](https://github.com/lilydjwg/userscripts/raw/master/docsrs.user.js)
22 |
23 | element
24 | ===
25 |
26 | For the Element Web Matrix client.
27 |
28 | * mark Telegram bridge users with a small icon at the corner of avatar
29 |
30 | [Install](https://github.com/lilydjwg/userscripts/raw/master/element.user.js)
31 |
32 | Arch Packages time
33 | ===
34 |
35 | Use local time format for package dates.
36 |
37 | [Install](https://github.com/lilydjwg/userscripts/raw/master/arch-packages.user.js)
38 |
39 | zhihu-tweak
40 | ===
41 | * 问答
42 | * 评论时,Tab 之后首先跳转到提交评论的按钮
43 | * 文章
44 | * 修复中键/Ctrl+左键点击在后台标签页中打开链接
45 | * 图片、视频立即加载不等待,GIF 自动播放
46 | * TODO: 刷新之后,浏览器无法恢复当前滚动位置
47 |
48 | [Install](https://github.com/lilydjwg/userscripts/raw/master/zhihu-tweak.user.js)
49 |
50 | wikipedia-lang-reorder
51 | ===
52 | * Move Chinese and English languages to the front in the language list
53 | * Hide Translate link
54 | * For Vector 2022 theme, copy the language list back to bottom of left column
55 |
56 | [Install](https://github.com/lilydjwg/userscripts/raw/master/wikipedia-lang-reorder.user.js)
57 |
58 | google_cache_redirect
59 | ===
60 | * link for Google Search to bypass redirecting (for visiting or copying)
61 | * no unencrypted URL redirecting
62 |
63 | [Install](https://github.com/lilydjwg/userscripts/raw/master/google_cache_redirect.user.js)
64 |
65 | google_searchbar
66 | ===
67 | * middle-click clear & paste on Google Searchbar (hold alt to not clear)
68 |
69 | [Install](https://github.com/lilydjwg/userscripts/raw/master/google_searchbar.user.js)
70 |
71 | readthedocs
72 | ===
73 | * Toggle navigation column to save space
74 |
75 | [Install](https://github.com/lilydjwg/userscripts/raw/master/readthedocs.user.js)
76 |
77 | telegram-web
78 | ===
79 | * make the link in unsafe link popups a real link
80 |
81 | [Install](https://github.com/lilydjwg/userscripts/raw/master/telegram-web.user.js)
82 |
83 | ipip-tweak
84 | ===
85 | * DNS 查询页面清除输入框并聚集
86 |
87 | [Install](https://github.com/lilydjwg/userscripts/raw/master/ipip-tweak.user.js)
88 |
89 | googlegroups_remove_translation_tip
90 | ===
91 | * Don't show the translate-to-Chinese tip. It's annoying.
92 |
93 | [Install](https://github.com/lilydjwg/userscripts/raw/master/googlegroups_remove_translation_tip.user.js)
94 |
95 | visited-links
96 | ===
97 | * use purple (or other) color for visited links
98 |
99 | [Install](https://github.com/lilydjwg/userscripts/raw/master/visited-links.user.js)
100 |
101 | chito
102 | ===
103 | * show IP geolocations in Chito admin pages
104 |
105 | This script requires a local HTTP service.
106 |
107 | [Install](https://github.com/lilydjwg/userscripts/raw/master/chito.user.js)
108 |
109 | 汉典
110 | ===
111 | * 生僻字使用文字显示
112 |
113 | [Install](https://github.com/lilydjwg/userscripts/raw/master/zdic.user.js)
114 |
115 | aqistudy
116 | ===
117 | * 修复主内容区域不能正确显示的问题
118 |
119 | [Install](https://github.com/lilydjwg/userscripts/raw/master/aqistudy.user.js)
120 |
121 | mp.weixin
122 | ===
123 | * 修正微信文章标题
124 |
125 | [Install](https://github.com/lilydjwg/userscripts/raw/master/mp.weixin.user.js)
126 |
127 | cks
128 | ===
129 | * Make titles of Chris's Wiki better
130 |
131 | [Install](https://github.com/lilydjwg/userscripts/raw/master/cks.user.js)
132 |
133 | Bilibili
134 | ===
135 | B 站优化。
136 |
137 | * 禁用自动静音播放
138 | * 移除未登录的各种烦人提示
139 | * 双击视频播放器切换全屏
140 |
141 | [Install](https://github.com/lilydjwg/userscripts/raw/master/bilibili.user.js)
142 |
143 | Taobao
144 | ===
145 | 淘宝优化。
146 |
147 | * 禁用 Alt+数字快捷键(与 Linux 下浏览器切换标签页冲突)
148 |
149 | [Install](https://github.com/lilydjwg/userscripts/raw/master/taobao.user.js)
150 |
151 | Duolingo
152 | ===
153 | Duolingo 优化
154 |
155 | * 中国大陆网民也要有朋友!
156 |
157 | [Install](https://github.com/lilydjwg/userscripts/raw/master/duolingo.user.js)
158 |
--------------------------------------------------------------------------------
/android/bilibili.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name bilibili background play
3 | // @namespace https://github.com/lilydjwg/userscripts
4 | // @description bilibili background play
5 | // @include https://*.bilibili.com/*
6 | // @version 0.1
7 | // @grant none
8 | // ==/UserScript==
9 |
10 | 'use strict'
11 |
12 | window.addEventListener('visibilitychange', evt => {
13 | evt.stopImmediatePropagation()
14 | }, true)
15 |
16 | document.addEventListener('click', evt => {
17 | if(evt.target.matches('#player_fullpage *')) {
18 | const v = document.querySelector('video')
19 | v.requestFullscreen()
20 | evt.stopImmediatePropagation()
21 | }
22 | }, true)
23 |
--------------------------------------------------------------------------------
/aqistudy.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name aqistudy fixes
3 | // @namespace https://github.com/lilydjwg/userscripts
4 | // @description aqistudy fixes
5 | // @include https://www.aqistudy.cn/*
6 | // @version 0.1
7 | // @grant none
8 | // ==/UserScript==
9 |
10 | (function() {
11 | 'use strict'
12 |
13 | function fix() {
14 | console.log('fixing')
15 | const el = document.getElementById('maintabs')
16 | if(!el){
17 | console.log('maintabs not found')
18 | return
19 | }
20 |
21 | const right_panel = el.lastChild
22 | if(!right_panel){
23 | console.log('right_panel not found')
24 | return
25 | }
26 |
27 | const {y, width} = right_panel.getBoundingClientRect()
28 | console.log('y, width=', y, width)
29 | if(y > window.innerHeight / 2){
30 | right_panel.style.width = `${width-1}px`
31 | }
32 |
33 | }
34 |
35 | window.addEventListener('resize', function(){
36 | // run after content scripts
37 | setTimeout(fix, 200)
38 | })
39 | fix()
40 |
41 | })()
42 |
--------------------------------------------------------------------------------
/arch-packages.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Arch Packages time
3 | // @namespace https://github.com/lilydjwg/userscripts
4 | // @version 0.3
5 | // @description use local time format for package dates
6 | // @match https://archlinux.org/packages/*
7 | // @require https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.12/dayjs.min.js
8 | // @require https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.12/locale/en.min.js
9 | // @require https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.12/plugin/customParseFormat.min.js
10 | // @grant none
11 | // ==/UserScript==
12 |
13 | 'use strict'
14 |
15 | function format_relative_time(d1, d2) {
16 | // in miliseconds
17 | const units = {
18 | year: 24 * 60 * 60 * 1000 * 365,
19 | month: (24 * 60 * 60 * 1000 * 365) / 12,
20 | day: 24 * 60 * 60 * 1000,
21 | hour: 60 * 60 * 1000,
22 | minute: 60 * 1000,
23 | second: 1000,
24 | };
25 |
26 | const rtf = new Intl.RelativeTimeFormat()
27 | // https://stackoverflow.com/a/60688789
28 | const elapsed = d1.valueOf() - d2.valueOf()
29 |
30 | for (const [u, period] of Object.entries(units)) {
31 | if (Math.abs(elapsed) > period || u === "second") {
32 | // https://stackoverflow.com/a/64972112
33 | return rtf.format(
34 | Math.round(elapsed / period),
35 | u
36 | )
37 | }
38 | }
39 | }
40 |
41 | // July 31, 2024, 6:45 a.m. UTC
42 | const parse_format = 'MMMM D, YYYY, H:mm a ZZ'
43 | const NOW = new Date()
44 |
45 | function parse_date(t) {
46 | t = t.replace(/([ap])\.m\./, '$1m')
47 | t = t.replace('UTC', '+0000')
48 | // e.g. Dec. 22, 2023, 11 p.m. UTC
49 | t = t.replace(/( [0-9]+) ([ap]m)/, '$1:00 $2')
50 | return dayjs(t, parse_format, 'en')
51 | }
52 |
53 | {
54 | const nodes = document.evaluate('//table[@id="pkginfo"]//td[contains(text(), "UTC")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)
55 | for(let i=0, len=nodes.snapshotLength; i