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 /res/client.js | |
| parent | f61717fcc48fe7039cab5e183da29653e445f691 (diff) | |
Fix twitch iframes
You also don't need to change `parent` arg in iframe src now
Diffstat (limited to 'res/client.js')
| -rw-r--r-- | res/client.js | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/res/client.js b/res/client.js index cdfee99..27b5f95 100644 --- a/res/client.js +++ b/res/client.js @@ -3021,6 +3021,9 @@ client_Player.prototype = { if(!this.isLoaded) { return; } + if(!this.isSyncActive()) { + return; + } if(this.videoList.items.length == 0) { return; } @@ -3057,6 +3060,9 @@ client_Player.prototype = { if(!this.isLoaded) { return; } + if(!this.isSyncActive()) { + return; + } var _this = this.videoList; var tmp = _this.items[_this.pos]; if(tmp == null) { @@ -3316,8 +3322,19 @@ client_Player.prototype = { } return this.player.isVideoLoaded(); } - ,play: function() { + ,isSyncActive: function() { if(!this.main.isSyncActive) { + return false; + } + var _this = this.videoList; + var tmp = _this.items[_this.pos]; + if(tmp == null) { + return false; + } + return tmp.playerType != "IframeType"; + } + ,play: function() { + if(!this.isSyncActive()) { return; } if(this.player == null) { @@ -3339,7 +3356,7 @@ client_Player.prototype = { } } ,pause: function() { - if(!this.main.isSyncActive) { + if(!this.isSyncActive()) { return; } if(this.player == null) { @@ -3367,7 +3384,7 @@ client_Player.prototype = { if(isLocal == null) { isLocal = true; } - if(!this.main.isSyncActive) { + if(!this.isSyncActive()) { return; } if(this.player == null) { @@ -3395,7 +3412,7 @@ client_Player.prototype = { if(isLocal == null) { isLocal = true; } - if(!this.main.isSyncActive) { + if(!this.isSyncActive()) { return; } if(this.player == null) { @@ -3445,7 +3462,7 @@ client_Player.prototype = { } }; http.onError = function(msg) { - haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 666, className : "client.Player", methodName : "skipAd"}); + haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 674, className : "client.Player", methodName : "skipAd"}); }; http.request(); } @@ -3765,7 +3782,7 @@ client_players_Iframe.prototype = { var iframe = window.document.createElement("div"); iframe.innerHTML = StringTools.trim(data.url); if(this.isValidIframe(iframe)) { - callback({ duration : 356400}); + callback({ duration : 356400, title : "Iframe media"}); } else { callback({ duration : 0}); } @@ -3783,13 +3800,22 @@ client_players_Iframe.prototype = { ,loadVideo: function(item) { this.removeVideo(); this.video = window.document.createElement("div"); - this.video.innerHTML = item.url; + var data = item.url; + if(data.indexOf("player.twitch.tv") != -1) { + var hostname = $global.location.hostname; + data = StringTools.replace(data,"parent=www.example.com","parent=" + hostname); + if(!new EReg("[A-z]","").match(hostname)) { + client_Main.instance.serverMessage("Twitch player blocks access from ips, please use SyncTube from any domain for it.\nYou can register some on <a href=\"https://nya.pub\" target=\"_blank\">nya.pub</a>.",false); + } + } + this.video.innerHTML = data; if(!this.isValidIframe(this.video)) { this.video = null; return; } if(this.video.firstChild.nodeName == "IFRAME") { this.video.setAttribute("sandbox","allow-scripts"); + this.video.classList.add("videoplayerIframeParent"); } this.video.firstElementChild.id = "videoplayer"; this.playerEl.appendChild(this.video); |
