param( [string]$IndexPath = "" ) $ErrorActionPreference = "Stop" $loaderSrc = "/Requests/Assets/nav-loader.js" $markerStart = "" $markerEnd = "" if (-not $IndexPath) { $candidates = @( (Join-Path $env:LOCALAPPDATA "jellyfin\jellyfin-web\index.html"), "C:\Program Files\Jellyfin\Server\jellyfin-web\index.html", "C:\ProgramData\Jellyfin\Server\jellyfin-web\index.html" ) foreach ($candidate in $candidates) { if (Test-Path $candidate) { $IndexPath = $candidate break } } } if (-not $IndexPath -or -not (Test-Path $IndexPath)) { Write-Error "Could not find jellyfin-web index.html. Pass -IndexPath explicitly." } $html = Get-Content -Raw -Path $IndexPath if (($html -notlike "*$loaderSrc*") -and ($html -notlike "*$markerStart*")) { Write-Host "Request web loader is not installed in $IndexPath" exit 0 } $backupPath = "$IndexPath.bak.request.uninstall.$(Get-Date -Format 'yyyyMMddHHmmss')" Copy-Item -Path $IndexPath -Destination $backupPath $pattern = "(?s)\s*$([regex]::Escape($markerStart)).*?$([regex]::Escape($markerEnd))\s*" $updated = [regex]::Replace($html, $pattern, "`r`n") $updated = [regex]::Replace($updated, "(?im)^\s*]*nav-loader\.js[^>]*>\s*\s*`r?`n?", "") Set-Content -Path $IndexPath -Value $updated -NoNewline Write-Host "Removed Request web loader from $IndexPath" Write-Host "Backup saved to $backupPath"