Skip to content

Commit 85fc94f

Browse files
committed
feat(隐藏): 添加一个设置用于隐藏未更新的脚本
感谢 #184
1 parent 5f93975 commit 85fc94f

3 files changed

Lines changed: 62 additions & 12 deletions

File tree

CONTRIBUTORS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
- [@Guany725](https://github.com/Guany725)[#50](https://github.com/ChinaGodMan/UserScripts/issues/50) 反馈了无法跨域设置窗口大小的问题(已解决)
2222
- [德克斯 dex](https://greasyfork.org/users/20361)[#258907](https://greasyfork.org/scripts/504880/discussions/258907#comment-529624) 添加了记录窗口大小的代码
2323

24+
### [Greasyfork 未更新腳本高亮](./greasyfork-ugreasyfork-unupdated-scriptscript)
25+
26+
- [Mateo Bohorquez G.](https://github.com/Milor123)[#184](https://github.com/ChinaGodMan/UserScripts/issues/184) 头脑风暴了一个`隐藏未更新脚本的` 新功能
27+
2428
**原始脚本来源请查看每个脚本目录下的`AUTHORS.md`**
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# **🛠️ Greasyfork 未更新脚本高亮 更新日志**
2+
3+
### **📅 2025.8.26.1**
4+
5+
**新增**: 隐藏**未更新的脚本**[#184](https://github.com/ChinaGodMan/UserScripts/issues/184)

greasyfork-unupdated-script/greasyfork-unupdated-script.user.js

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,31 @@
361361
// @compatible qq
362362
// @compatible via
363363
// @compatible brave
364-
// @version 2025.6.4.1
364+
// @version 2025.8.26.1
365365
// @grant GM_setValue
366366
// @grant GM_getValue
367367
// @grant GM_registerMenuCommand
368+
// @grant GM_unregisterMenuCommand
368369
// @downloadURL https://raw.githubusercontent.com/ChinaGodMan/UserScripts/main/greasyfork-unupdated-script/greasyfork-unupdated-script.user.js
369370
// @updateURL https://raw.githubusercontent.com/ChinaGodMan/UserScripts/main/greasyfork-unupdated-script/greasyfork-unupdated-script.user.js
370371
// ==/UserScript==
371372

373+
/**
374+
* File: greasyfork-unupdated-script.user.js
375+
* Project: UserScripts
376+
* File Created: 2025/06/04,Wednesday 09:23:41
377+
* Author: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
378+
* -----
379+
* Last Modified: 2025/08/26,Tuesday 22:47:48
380+
* Modified By: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
381+
* -----
382+
* License: MIT License
383+
* Copyright © 2024 - 2025 ChinaGodMan,Inc
384+
*/
385+
372386
const Days = GM_getValue('days', 30) // 默认30天
373387
const threshold = Days * 24 * 60 * 60 * 1000
374-
GM_registerMenuCommand('Settings', () => {
388+
GM_registerMenuCommand('Days', () => {
375389
const userInput = prompt('Enter the number of days:', Days)
376390
if (userInput !== null) {
377391
const parsedInput = parseInt(userInput, 10)
@@ -382,14 +396,41 @@ GM_registerMenuCommand('Settings', () => {
382396
}
383397
}
384398
})
385-
document.querySelectorAll('dd.script-list-updated-date').forEach(function (dd) {
386-
const relativeTime = dd.querySelector('relative-time')
387-
if (relativeTime) {
388-
const time1 = new Date(relativeTime.getAttribute('datetime'))
389-
const time2 = new Date()
390-
if (time2.getTime() - time1.getTime() > threshold) {
391-
relativeTime.style.color = 'red'
392-
dd.closest('li').style.background = '#ff000008'
399+
let menuId
400+
function Toggle() {
401+
if (menuId) { GM_unregisterMenuCommand(menuId) }
402+
let HideScript = GM_getValue('HideScript', false)
403+
menuId = GM_registerMenuCommand(
404+
(HideScript ? '✅ ' : '❌ ') + 'HideScript',
405+
() => {
406+
HideScript = !HideScript
407+
GM_setValue('HideScript', HideScript)
408+
Toggle()
409+
if (!HideScript) {
410+
document.querySelectorAll('dd.script-list-updated-date').forEach(function (dd) {
411+
const li = dd.closest('li')
412+
if (li) { li.style.display = 'list-item' }
413+
})
414+
} else {
415+
GO()
416+
}
393417
}
394-
}
395-
})
418+
)
419+
}
420+
421+
Toggle()
422+
GO()
423+
function GO() {
424+
document.querySelectorAll('dd.script-list-updated-date').forEach(function (dd) {
425+
const relativeTime = dd.querySelector('relative-time')
426+
if (relativeTime) {
427+
const time1 = new Date(relativeTime.getAttribute('datetime'))
428+
const time2 = new Date()
429+
if (time2.getTime() - time1.getTime() > threshold) {
430+
relativeTime.style.color = 'red'
431+
dd.closest('li').style.background = '#ff000008'
432+
if (GM_getValue('HideScript', false)) { dd.closest('li').style.display = 'none' }
433+
}
434+
}
435+
})
436+
}

0 commit comments

Comments
 (0)