-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
hide-user-forks.tsx
40 lines (30 loc) · 1.04 KB
/
hide-user-forks.tsx
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
import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';
function addSourceTypeToLink(link: HTMLAnchorElement): void {
const search = new URLSearchParams(link.search);
search.set('type', 'source');
link.search = String(search);
}
const skipUrlsWithType = ':not([href*="&type="], .issues-reset-query)';
const selectors = [
// User repos
`a[href*="?tab=repositories"]:is([href^="/"], [href^="${location.origin}/"])${skipUrlsWithType}`,
// Organization repos
`a[href*="/repositories"]:is([href^="/orgs/"], [href^="${location.origin}/orgs/"])${skipUrlsWithType}`,
] as const;
// No `include`, no `signal` necessary
function init(): void {
observe(selectors, addSourceTypeToLink);
}
void features.add(import.meta.url, {
init,
});
/*
## Test URLs
- https://github.com/fregante?tab=repositories
- https://github.com/orgs/refined-github/repositories
- The "Your repositories" link in the user dropdown in the header
- The "Repositories" tab in
- https://github.com/fregante
- https://github.com/refined-github
*/