Repository navigation
Expand file tree
/
Copy pathscript.user.js
More file actions
117 lines (103 loc) · 3.06 KB
/
Copy pathscript.user.js
File metadata and controls
117 lines (103 loc) · 3.06 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// ==UserScript==
// @name GitHub: Undiscovered Trending
// @namespace shiftgeist
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @version 20251110.0
//
// @match https://github.com/trending*
// @grant none
// @run-at document-idle
//
// @author shiftgeist
// @description Hide starred repos in trending and remove slob
// @license GNU GPLv3
//
// @updateURL https://raw.githubusercontent.com/shiftgeist/userscripts/refs/heads/main/github.com/undiscovered-trending/script.user.js
// @downloadURL https://raw.githubusercontent.com/shiftgeist/userscripts/refs/heads/main/github.com/undiscovered-trending/script.user.js
// ==/UserScript==
const ignoreKeywordsInText = [
' ai ',
'ai assistant',
'ai chat',
'ai models',
'ai-powered',
'crypto',
'deepseek',
'defi',
'gemini',
'gpt',
'llm',
'mcp',
'ollama',
'openai',
'qwenlm',
'deep learning'
]
function log(...params) {
if (localStorage.getItem('undiscovered-debug') === 'true') {
console.log('[undiscovered]', ...params)
}
}
function createIgnoreButton(ignoredRepos, urlToIgnore, onclick) {
const button = document.createElement('button')
button.className = 'Button--secondary Button--small Button ml-2 ignore-button'
button.innerText = 'Ignore'
button.onclick = () => {
ignoredRepos.push(urlToIgnore)
onclick()
localStorage.setItem('undiscovered-ignored', JSON.stringify(ignoredRepos))
}
return button
}
function main() {
log('start of main')
setTimeout(() => {
log('delay done')
const ignoredRepos = JSON.parse(
localStorage.getItem('undiscovered-ignored') || '[]'
)
const articles = document.querySelectorAll('article')
const parent = document.querySelector('[data-hpc=""]')
for (const article of articles) {
const url = article.querySelector('h2 a').getAttribute('href')
const hasButton = article.querySelector('.ignore-button')
const buttonsContainer = article.querySelector('.float-right.d-flex')
if (!hasButton) {
function onclick() {
article.remove()
main()
}
const button = createIgnoreButton(ignoredRepos, url, onclick)
buttonsContainer.append(button)
}
if (
// Already starred
article.querySelector('.starred-button-icon').getClientRects().length
> 0
// Ignored
|| ignoredRepos.includes(url)
// Contains AI
|| ignoreKeywordsInText.findIndex((e) => article.innerText.toLowerCase().includes(e)) >= 0
) {
article.remove()
}
}
// no repos dispalyed
if (parent.childElementCount === 0) {
const empty = document.createElement('article')
empty.className = 'Box-row'
empty.innerText = 'Nothing to discover'
parent.append(empty)
}
}, 100)
}
log('init')
let previousUrl = ''
const observer = new MutationObserver(function() {
if (location.href !== previousUrl) {
previousUrl = location.href
main()
}
})
const config = { subtree: true, childList: true }
observer.observe(document, config)