# Leansoft Drama - open the website in a separate Chrome/Edge window that keeps downloading while the screen is locked. # Only this window uses the settings below; the user's normal browser profile is untouched. Safe to run again. $ErrorActionPreference = 'Stop' $url = 'https://dramashort-downloader.leansoft-ai.com/?bg=1' $profileDir = Join-Path $env:LOCALAPPDATA 'LeansoftDramaChrome' $browser = @( (Join-Path $env:ProgramFiles 'Google\Chrome\Application\chrome.exe'), (Join-Path ${env:ProgramFiles(x86)} 'Google\Chrome\Application\chrome.exe'), (Join-Path $env:LOCALAPPDATA 'Google\Chrome\Application\chrome.exe'), (Join-Path ${env:ProgramFiles(x86)} 'Microsoft\Edge\Application\msedge.exe'), (Join-Path $env:ProgramFiles 'Microsoft\Edge\Application\msedge.exe') ) | Where-Object { Test-Path $_ } | Select-Object -First 1 if (-not $browser) { Write-Host 'Chua co Google Chrome. Cai tai https://www.google.com/chrome/ roi chay lai lenh nay.'; return } $flags = @("--user-data-dir=`"$profileDir`"", '--no-first-run', '--no-default-browser-check', '--disable-background-timer-throttling', '--disable-renderer-backgrounding', '--disable-backgrounding-occluded-windows', $url) $process = Start-Process -FilePath $browser -ArgumentList $flags -PassThru # ES_CONTINUOUS | ES_SYSTEM_REQUIRED: the PC stays awake (screen may still turn off and lock) while this window is open. Add-Type -Namespace LeansoftDrama -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint flags);' [LeansoftDrama.Power]::SetThreadExecutionState([uint32]'0x80000001') | Out-Null Write-Host '' Write-Host 'Da mo trinh duyet o che do chay nen. Dang nhap, nhan batch, bam Download now.' Write-Host 'GIU CUA SO NAY MO (co the thu nho). Co the khoa man hinh (Win+L). Nen cam sac khi tai lau.' try { Wait-Process -Id $process.Id -ErrorAction SilentlyContinue } finally { [LeansoftDrama.Power]::SetThreadExecutionState([uint32]'0x80000000') | Out-Null } Write-Host 'Da dong trinh duyet chay nen; may co the ngu lai binh thuong.'