From 96a5d173f17bc99946782d191463e5ee60bc12a2 Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 4 Dec 2025 17:27:20 +0100 Subject: [PATCH] [Glitch] Fixes YouTube embeds Port 9bc9ebc59ef534a9987c9d6dc5450e322ffc1741 to glitch-soc Signed-off-by: Claire --- .../glitch/features/status/components/card.jsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/features/status/components/card.jsx b/app/javascript/flavours/glitch/features/status/components/card.jsx index de644aa0e6..6eec38adf1 100644 --- a/app/javascript/flavours/glitch/features/status/components/card.jsx +++ b/app/javascript/flavours/glitch/features/status/components/card.jsx @@ -29,17 +29,20 @@ const domParser = new DOMParser(); const handleIframeUrl = (html, url, providerName) => { const document = domParser.parseFromString(html, 'text/html').documentElement; const iframe = document.querySelector('iframe'); - const startTime = new URL(url).searchParams.get('t') + const startTime = new URL(url).searchParams.get('t'); if (iframe) { - const iframeUrl = new URL(iframe.src) + const iframeUrl = new URL(iframe.src); - iframeUrl.searchParams.set('autoplay', 1) - iframeUrl.searchParams.set('auto_play', 1) + iframeUrl.searchParams.set('autoplay', 1); + iframeUrl.searchParams.set('auto_play', 1); - if (startTime && providerName === "YouTube") iframeUrl.searchParams.set('start', startTime) + if (providerName === 'YouTube') { + iframeUrl.searchParams.set('start', startTime || ''); + iframe.referrerPolicy = 'strict-origin-when-cross-origin'; + } - iframe.src = iframeUrl.href + iframe.src = iframeUrl.href; // DOM parser creates html/body elements around original HTML fragment, // so we need to get innerHTML out of the body and not the entire document