blob: af7a18a42c811507312742dc7a0f7c53b38daa51 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import {$} from 'select-dom';
import oneMutation from 'one-mutation';
export default async function getTabCount(tab: Element): Promise<number> {
const counter = $('.Counter, .num', tab);
if (!counter) {
// GitHub might have already dropped the counter, which means it's 0
return 0;
}
if (!counter.firstChild) {
// It's still loading
await oneMutation(tab, {childList: true, subtree: true});
}
return Number(counter.textContent);
}
|