aboutsummaryrefslogtreecommitdiffstats
path: root/content.js
blob: ab420805ef82326d527a1f8cd2885688ce823621 (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
39
40
41
42
43
function with_player (callback) {
	var interval = setInterval(
		function() {
			var player = document.querySelector('.NFPlayer.nf-player-container');

			if (player) {
				clearInterval(interval);

				callback(player);
			}
		},
		1000
	);
}

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

			if (mutation.target.classList.contains('postplay')) {
				mutation.target.classList.remove('postplay');

				return;
			}
		}
	});

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


with_player(function(player) {
	window.player = player;

	init_mutation_observer(player);
});