NSFW communities are often a mixture of redgifs videos (which play automatically) and <video> elements linking to mp4s which don’t. This script evens the playing field so mp4 videos autoplay as well. Hover your mouse over the video and it’ll unmute.
document.addEventListener("DOMContentLoaded", () => {
const videos = document.querySelectorAll("video");
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.play().catch(err => {
console.warn("Autoplay blocked:", err);
});
} else {
entry.target.pause();
}
});
}, { threshold: 0.5 });
videos.forEach(video => {
video.muted = true; // ensure muted initially
observer.observe(video);
video.addEventListener("mouseenter", () => {
video.muted = false; // unmute on hover
});
video.addEventListener("mouseleave", () => {
video.muted = true; // re-mute when not hovered
});
});
});
Put it into the ‘Additional JS’ field in /admin/misc.
You must log in or # to comment.

