JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p><iframe src="//www.youtube.com/embed/rk7_dXIKt0Y?start=1" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen" allow="autoplay"></iframe></p>
</body>
</html>
JavaScript
// RegEx Source: https://stackoverflow.com/a/37704433/362536
const youtubeUrlPattern = /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/;
[...document.querySelectorAll('iframe')].filter((iframeEl) => {
// Filter to iframes loading YouTube URLs only.
return iframeEl.src.match(youtubeUrlPattern);
}).forEach((iframeEl) => {
const a = document.createElement('a');
a.href = iframeEl.src;
a.search = a.search || '?';
a.search += '&autoplay=1&mute=1';
iframeEl.src = a.href;
});