06-oct: [omniroute] re-auth provider Claude + helper OAuth y vigilante portapapeles
This commit is contained in:
24
omniroute/clipboard_watch.ps1
Normal file
24
omniroute/clipboard_watch.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
$codeFile = "C:\Users\juanm\Documents\Github\INFRAESTRUCTURA\omniroute\oauth_code.txt"
|
||||
$exitFile = "C:\Users\juanm\Documents\Github\INFRAESTRUCTURA\omniroute\oauth_helper.exit"
|
||||
$last = ""
|
||||
try { $last = [System.Windows.Forms.Clipboard]::GetText() } catch {}
|
||||
$deadline = (Get-Date).AddMinutes(20)
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
if (Test-Path $exitFile) { break }
|
||||
$c = ""
|
||||
try { $c = [System.Windows.Forms.Clipboard]::GetText() } catch {}
|
||||
if ($c -and $c -ne $last -and $c.Length -ge 20 -and ($c -match "#" -or $c -match "code=")) {
|
||||
# Limpiar espacios/saltos por si copia con formato
|
||||
$clean = $c.Trim()
|
||||
if ($clean -match "https?://") {
|
||||
$m = [regex]::Match($clean, "code=([^&#\s]+)")
|
||||
$s = [regex]::Match($clean, "state=([^&#\s]+)")
|
||||
if ($m.Success -and $s.Success) { $clean = $m.Groups[1].Value + "#" + $s.Groups[1].Value }
|
||||
}
|
||||
Set-Content -Path $codeFile -Value $clean -NoNewline
|
||||
break
|
||||
}
|
||||
$last = $c
|
||||
Start-Sleep -Milliseconds 700
|
||||
}
|
||||
Reference in New Issue
Block a user