From c64bbaca4dc9977eae5b0068ee580b96ba057cb2 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 5 May 2020 02:40:41 +0200 Subject: Use `classList.remove()` Turns out `classList` isn't an array, it's a `DOMTokenList`, and it doesn't have an `includes()` method. Instead, use `contains()`. `DOMTokenList` also doesn't have a `filter()`, but we can remove the `.postplay` class much easier with the `remove()` method. Turns out I didn't need to worry about a `childList` mutation observer as I previously thought. This version works. Now that the class is removed, the video no longer reduces to the small frame. --- content.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/content.js b/content.js index 977f170..ab42080 100644 --- a/content.js +++ b/content.js @@ -18,16 +18,10 @@ function init_mutation_observer (player) { 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'; - }); + if (mutation.target.classList.contains('postplay')) { + mutation.target.classList.remove('postplay'); + + return; } } }); @@ -43,5 +37,7 @@ function init_mutation_observer (player) { with_player(function(player) { + window.player = player; + init_mutation_observer(player); }); -- cgit v1.2.3