Fix youtube not showing properly

This commit is contained in:
Redox 2023-06-24 02:53:46 +02:00
parent d352044a63
commit c8569ffcbf
No known key found for this signature in database
GPG Key ID: C10A433A95068388

View File

@ -111,8 +111,11 @@ function PANEL:Think()
end
function PANEL:FetchPageURL()
local js = "gmod.getUrl(window.location.href);"
self:RunJavascript(js)
self:AddFunction( "gmod", "getUrl", function( geturl )
self:SetURL( geturl )
end )
self:RunJavascript( [[gmod.getUrl(window.location.href);]] )
end
function PANEL:GetURL()
@ -481,4 +484,20 @@ function PANEL:MoveToCursor( xoffset, yoffset )
self:SetPos( cx - xoffset, cy - yoffset )
end
-- Youtube specific fix
function PANEL:OnDocumentReady( url )
if url ~= "https://www.youtube.com/" then return end
self:AddFunction( "gmod", "getUrl", function( geturl )
self:SetURL( geturl )
end )
self:QueueJavascript( [[
function run(){
if (typeof gmod == "undefined") { return };
gmod.getUrl(window.location.href);
};
window.addEventListener( 'yt-navigate-start', run, true )
]] )
end
derma.DefineControl( "DMediaPlayerHTML", "", PANEL, "Awesomium" )