aboutsummaryrefslogtreecommitdiffstats
path: root/src/wait_element.ts
blob: f24b8917e21f31d02772cae926fe9ffdaf78ec02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
export default function wait_element (selector: string): Promise<Element> {
	return new Promise(function(resolve) {
		const interval = setInterval(
			function() {
				const element = document.querySelector(selector);

				if (element) {
					clearInterval(interval);

					resolve(element);
				}
			},
			1000
		);
	});
}