From 1eb99d35545e7134dccf5b71490138d2c6cd00e5 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 7 Jan 2020 15:38:51 +0100 Subject: [PATCH] Set youtube viewport before DOMContentLoaded --- .../main/assets/web_extensions/webcompat_youtube/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/web_extensions/webcompat_youtube/main.js b/app/src/main/assets/web_extensions/webcompat_youtube/main.js index 151a7b7de..812e77894 100644 --- a/app/src/main/assets/web_extensions/webcompat_youtube/main.js +++ b/app/src/main/assets/web_extensions/webcompat_youtube/main.js @@ -31,9 +31,10 @@ class YoutubeExtension { if (viewport) { viewport.setAttribute('content', content); } else { - document.head.insertAdjacentHTML('afterbegin', ``); + const container = document.head || document.documentElement; + container.insertAdjacentHTML('afterbegin', ``); } - logDebug(`Youtube viewport updated`); + logDebug(`Youtube viewport updated: ${window.innerWidth}x${window.innerHeight} `); } // Select a better youtube video quality @@ -203,7 +204,7 @@ class YoutubeExtension { logDebug(`Initializing youtube extension in frame: ${window.location.href}`); const youtube = new YoutubeExtension(); youtube.overrideUA(); -window.addEventListener('DOMContentLoaded', () => youtube.overrideViewport()); +youtube.overrideViewport(); window.addEventListener('load', () => { logDebug('page load'); youtube.overrideVideoProjection();