From a01327bdc7d6deade1ad113d85859e11d4bd846d Mon Sep 17 00:00:00 2001 From: dimden Date: Sun, 8 Oct 2023 19:30:37 +0300 Subject: [PATCH] dont constantly play gif videos --- layouts/header/script.js | 12 ++++++++++++ scripts/helpers.js | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/layouts/header/script.js b/layouts/header/script.js index c5cdce34..2c51a08c 100644 --- a/layouts/header/script.js +++ b/layouts/header/script.js @@ -2479,6 +2479,10 @@ let userDataFunction = async user => { qvideo.pause(); } } + let gifs = Array.from(activeTweet.querySelectorAll('.tweet-media > .tweet-media-gif')); + let qgifs = Array.from(activeTweet.querySelectorAll('.tweet-media-quote > .tweet-media-gif')); + gifs.forEach(gif => gif.pause()); + qgifs.forEach(gif => gif.pause()); if(activeTweet.tweet && activeTweet.tweet.algo) { if(!seenAlgoTweets.includes(activeTweet.tweet.id_str)) seenAlgoTweets.push(activeTweet.tweet.id_str); if(seenAlgoTweets.length > 100) { @@ -2499,6 +2503,14 @@ let userDataFunction = async user => { } } } + if(!vars.disableGifAutoplay) { + if(newActiveTweet) { + let newGifs = Array.from(newActiveTweet.querySelectorAll('.tweet-media > .tweet-media-gif')); + let newQGifs = Array.from(newActiveTweet.querySelectorAll('.tweet-media-quote > .tweet-media-gif')); + newGifs.forEach(gif => gif.play()); + newQGifs.forEach(gif => gif.play()); + } + } activeTweet = newActiveTweet; } }, { passive: true }); diff --git a/scripts/helpers.js b/scripts/helpers.js index f2608442..67104f62 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1379,7 +1379,6 @@ function renderMedia(t) { loop disableRemotePlayback onclick="if(this.paused) this.play(); else this.pause()" - ${vars.disableGifAutoplay ? '' : 'autoplay'} muted class="tweet-media-element tweet-media-gif ${mediaClasses[t.extended_entities.media.length]} ${toCensor ? 'tweet-media-element-censor' : ''}" >