Compare commits

...

3 Commits

Author SHA1 Message Date
Bruno Viveiros
77942c93e9
Merge e2cd3a5299 into c442589593 2025-07-10 08:04:32 +00:00
Bruno Viveiros
e2cd3a5299 fix: add provider_name check to card iframes 2024-01-23 08:50:13 -03:00
Bruno Viveiros
5ef167b4a8 fix: YouTube iframe being able to start at a defined time 2024-01-23 08:50:13 -03:00

View File

@ -37,18 +37,20 @@ const getHostname = url => {
const domParser = new DOMParser();
const addAutoPlay = html => {
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')
if (iframe) {
if (iframe.src.indexOf('?') !== -1) {
iframe.src += '&';
} else {
iframe.src += '?';
}
const iframeUrl = new URL(iframe.src)
iframe.src += 'autoplay=1&auto_play=1';
iframeUrl.searchParams.set('autoplay', 1)
iframeUrl.searchParams.set('auto_play', 1)
if (startTime && providerName === "YouTube") iframeUrl.searchParams.set('start', startTime)
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
@ -114,7 +116,7 @@ export default class Card extends PureComponent {
renderVideo () {
const { card } = this.props;
const content = { __html: addAutoPlay(card.get('html')) };
const content = { __html: handleIframeUrl(card.get('html'), card.get('url'), card.get('provider_name')) };
return (
<div