From c5eb7ee015af975d408d7814e34a3b8e2c963e75 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 5 May 2020 01:53:04 +0200 Subject: Try removing `postplay` class from player element Use a `MutationObserver` to get an event when the Netflix player's class attribute changes. Want to try removing the `.postplay` class, which makes the player reduce to a small frame. This doesn't currently work because when the player is reduced, a second player element is added to the DOM, and my reference no longer corresponds to the right player. Looks like I'll need to try adding a mutation observer on child elements, and watch for a new player element being added. --- content.js | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/content.js b/content.js index b6a0cdc..977f170 100644 --- a/content.js +++ b/content.js @@ -1,8 +1,47 @@ -// Didn't work -netflix.reactContext.models.truths.data.skipCreditsEnabled = false; +function with_player (callback) { + var interval = setInterval( + function() { + var player = document.querySelector('.NFPlayer.nf-player-container'); -// Didn't work -netflix.reactContext.models.truths.data['wwwplayer.config.skip.credits.enabled'] = false + if (player) { + clearInterval(interval); -// Didn't work -netflix.reactContext.models.fastProps.data['wwwplayer.config.skip.credits.enabled'] = false + 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); +}); -- cgit v1.2.3