INNER CODE UNIT · TypeScript

disableVideoAutoplay

sindresorhus/caprine · source/autoplay.ts:29

function disableVideoAutoplay(videos: NodeListOf<HTMLVideoElement>): void {
	for (const video of videos) {
		// Don't disable currently playing videos
		if (playedVideos.includes(video)) {
			continue;
		}

		const firstParent = video.parentElement!;

		// Video parent element which has a snapshot of the video as a background image
		const parentWithBackground = video.parentElement!.parentElement!.parentElement!;

		// Hold reference to the background parent so we can revert our changes
		const parentWithBackgroundParent = parentWithBackground.parentElement!;

		// Reference to the original play icon on top of the video
		const playIcon = video.nextElementSibling!.nextElementSibling! as HTMLElement;
		// If the video is playing, the icon is hidden

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…