diff options
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); |
