aboutsummaryrefslogtreecommitdiffstats
path: root/src/fullscreen_credits.ts
blob: d8b68b920d8b8f29f26bf5cffcdf2a67be3bc4d7 (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
48
49
50
51
52
53
54
import with_player from './player';


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];
			var player = mutation.target as HTMLElement;

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

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

				// TODO: Change .active to .inactive
				// mutation.target.classList.replace('active', 'inactive'); // Didn't work
				// Remove .can-resume: Removes white border on hover
				// PlayerControlsNeo__bottom-controls PlayerControlsNeo__bottom-controls--faded
				// PlayerControlsNeo__layout PlayerControlsNeo__layout--active
				// PlayerControlsNeo__layout PlayerControlsNeo__layout--inactive

				// document.querySelector('.PlayerControlsNeo__bottom-controls')
				// 	.classList
				// 	.add('PlayerControlsNeo__bottom-controls--faded');

				document.querySelector('.PlayerControlsNeo__layout.PlayerControlsNeo__layout--active')
					.classList
					.replace(
						'PlayerControlsNeo__layout--active',
						'PlayerControlsNeo__layout--inactive'
					);

				// .OriginalsPostPlay-BackgroundTrailer .BackToBrowse

				return;
			}
		}
	});

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

export default function init () {
	with_player().then(function(player) {
		init_mutation_observer(player);
	});
}