diff options
| author | RblSb <msrblsb@gmail.com> | 2025-04-07 19:24:35 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2025-04-07 19:29:06 +0300 |
| commit | 71160f8c35da6d40bad52cfecd7152c539dd85c6 (patch) | |
| tree | 907359be529f26774620e869ef6e10675af461c4 /src/client/players/Iframe.hx | |
| parent | f61717fcc48fe7039cab5e183da29653e445f691 (diff) | |
Fix twitch iframes
You also don't need to change `parent` arg in iframe src now
Diffstat (limited to 'src/client/players/Iframe.hx')
| -rw-r--r-- | src/client/players/Iframe.hx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/client/players/Iframe.hx b/src/client/players/Iframe.hx index 000bf8a..9c24aed 100644 --- a/src/client/players/Iframe.hx +++ b/src/client/players/Iframe.hx @@ -6,6 +6,7 @@ import Types.VideoDataRequest; import Types.VideoItem; import client.Main.getEl; import js.Browser.document; +import js.Browser; import js.html.Element; class Iframe implements IPlayer { @@ -31,7 +32,10 @@ class Iframe implements IPlayer { final iframe = document.createDivElement(); iframe.innerHTML = data.url.trim(); if (isValidIframe(iframe)) { - callback({duration: 99 * 60 * 60}); + callback({ + duration: 99 * 60 * 60, + title: "Iframe media", + }); } else { callback({duration: 0}); } @@ -46,13 +50,28 @@ class Iframe implements IPlayer { public function loadVideo(item:VideoItem):Void { removeVideo(); video = document.createDivElement(); - video.innerHTML = item.url; // actually data + var data = item.url; + + if (data.contains("player.twitch.tv")) { + final hostname = Browser.location.hostname; + data = data.replace("parent=www.example.com", 'parent=$hostname'); + if (!~/[A-z]/.match(hostname)) { + Main.instance.serverMessage( + 'Twitch player blocks access from ips, please use SyncTube from any domain for it. +You can register some on <a href="https://nya.pub" target="_blank">nya.pub</a>.', + false + ); + } + } + + video.innerHTML = data; if (!isValidIframe(video)) { video = null; return; } if (video.firstChild.nodeName == "IFRAME") { video.setAttribute("sandbox", "allow-scripts"); + video.classList.add("videoplayerIframeParent"); } video.firstElementChild.id = "videoplayer"; playerEl.appendChild(video); |
