blob: 2eecc3b8a348ccdc8f457564817d755fd1563db6 (
plain) (
blame)
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
|
/*
Hide other users starring/forking your repos
*/
import select from 'select-dom';
import features from '../libs/features';
import {getUsername} from '../libs/utils';
import {safeElementReady} from '../libs/dom-utils';
const observer = new MutationObserver(([{addedNodes}]) => {
// Remove events from dashboard
for (const item of select.all<HTMLElement>('#dashboard .news .watch_started, #dashboard .news .fork')) {
if (select(`a[href^="/${getUsername()}"]`, item)) {
item.style.display = 'none';
}
}
// Observe the new ajaxed-in containers
for (const node of addedNodes) {
if ((node as Element).tagName === 'DIV') {
observer.observe(node, {childList: true});
}
}
});
async function init() {
observer.observe(await safeElementReady('#dashboard .news'), {childList: true});
}
features.add({
id: 'hide-own-stars',
include: [
features.isDashboard
],
init
});
|