Functions/GenXdev.Webbrowser/Set-BrowserVideoFullscreen.ps1
<##############################################################################
Part of PowerShell module : GenXdev.Webbrowser Original cmdlet filename : Set-BrowserVideoFullscreen.ps1 Original author : René Vaessen / GenXdev Version : 1.268.2025 ################################################################################ MIT License Copyright 2021-2025 GenXdev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ################################################################################> ############################################################################### <# .SYNOPSIS Maximizes the first video element found in the current browser tab. .DESCRIPTION Executes JavaScript code to locate and maximize the first video element on the current webpage. The video is set to cover the entire viewport with maximum z-index to ensure visibility. Page scrollbars are hidden for a clean fullscreen experience. .EXAMPLE Set-BrowserVideoFullscreen #> function Set-BrowserVideoFullscreen { [CmdletBinding(SupportsShouldProcess)] [Alias('fsvideo')] param() begin { # prepare the javascript command that will handle video manipulation $script = @( "window.video = document.getElementsByTagName('video')[0];" + "video.setAttribute('style','position:fixed;left:0;top:0;bottom:0;" + "right:0;z-index:10000;width:100vw;height:100vh');" + 'document.body.appendChild(video);' + "document.body.setAttribute('style', 'overflow:hidden');" ) -join '' Microsoft.PowerShell.Utility\Write-Verbose 'Prepared JavaScript code for video fullscreen manipulation' } process { # check if we should proceed with the operation if ($PSCmdlet.ShouldProcess('browser video', 'Set to fullscreen mode')) { Microsoft.PowerShell.Utility\Write-Verbose 'Executing JavaScript to maximize video element' GenXdev.Webbrowser\Invoke-WebbrowserEvaluation $script } } end { } } |