Skip to content

Commit

Permalink
dont constantly play gif videos
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Oct 8, 2023
1 parent dc9fccc commit a01327b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 12 additions & 0 deletions layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 });
Expand Down
1 change: 0 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' : ''}"
>
Expand Down

0 comments on commit a01327b

Please sign in to comment.