blob: c7658395c2009c85e15b5834475c702ff9370188 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import select from 'select-dom';
import oneMutation from 'one-mutation';
export default async function getTabCount(tab: Element): Promise<number> {
const counter = select('.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);
}
|