raingart / Allow Fullscreen Youtube Embed

// ==UserScript==
// @name         Allow Fullscreen Youtube Embed
// @namespace    youtube-watch-to-embed
// @version      0.2
// @description  Enables the fullscreen button in all embedded youtube videos
// @author       raingart
// @include      *
// @run-at       document-end
// @license      Apache-2.0
// @noframes     
// ==/UserScript==
/*jshint esversion: 6 */

(function() {
const interval = setInterval(() => {
   let iframe_patched;

   document.body.querySelectorAll('iframe[src*="youtube"][src*="/embed/"]:not([allowfullscreen="true"])')
      .forEach(el => {
         el.setAttribute('allowfullscreen', 'true');
         el.setAttribute('frameborder', 0);
         //el.src += '&fs=1';
         iframe_patched = true;
      });
      
    if (iframe_patched) clearInterval(interval);

}, 1000);

// stop job
setTimeout(() => clearInterval(interval), 1000 * 10); // 10sec

})();