aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-05-05 01:53:04 +0200
committerTeddy Wing2020-05-05 02:39:32 +0200
commitc5eb7ee015af975d408d7814e34a3b8e2c963e75 (patch)
treeb96447e5c4228d03ef739021a8275c819d05a6b3
parent28eec915a92226520a9e761e12b86b7f7e87ab98 (diff)
downloadnetflix-immersive-c5eb7ee015af975d408d7814e34a3b8e2c963e75.tar.bz2
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.
-rw-r--r--content.js51
1 files 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);
+});