aboutsummaryrefslogtreecommitdiffstats
path: root/src/fullscreen_credits.ts
blob: 801165725bb53841b94aea93ba3b90f02347b49d (plain)
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
import controls from './controls';
import wait_element from './wait_element';


function init_mutation_observer (player) {
	const observer = new MutationObserver(function(mutation_list) {
		for (var i = 0; i < mutation_list.length; i++) {
			const mutation = mutation_list[i];
			const player = mutation.target as HTMLElement;

			if (player.classList.contains('postplay')) {
				player.classList.remove('postplay');

				// Activate player controls.
				player.click();

				controls.hide();

				return;
			}
		}
	});

	observer.observe(
		player,
		{
			attributeFilter: ['class'],
			attributeOldValue: true
		}
	);
}

export default function init () {
	wait_element('.NFPlayer.nf-player-container')
		.then(function(player) {
			init_mutation_observer(player);
		});
}