aboutsummaryrefslogtreecommitdiffstats
path: root/content.js
blob: 977f170a984a56774dcbd01ecd42b2a7bef60fc9 (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
44
45
46
47
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];

			console.log(
				mutation.target.className +
				'\n' +
				mutation.oldValue
			);

			if (mutation.target.classList.includes('postplay')) {
				mutation.target.classList = mutation.target.classList.filter(function(c) {
					return c !== 'postplay';
				});
			}
		}
	});

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


with_player(function(player) {
	init_mutation_observer(player);
});