User:SignpostMarv/common.js

const video_autoplay_via_class_observer = new IntersectionObserver(	function (videos, observer) {		videos.forEach(function (entry) { try { entry.target.play; observer.unobserve(entry.target); } catch (err) { console.error(err); }		});	},	{		root: document.getElementById('content'),	} );

document.querySelectorAll('#content video.autoplay:not([autoplay]),.page-content video.loop:not([loop])').forEach(function (video) {	if (video.classList.contains('autoplay')) {		video.autoplay = true;		video_autoplay_via_class_observer.observe(video);	}	if (video.classList.contains('loop')) {		video.loop = true;	} });