Files
DepressedCat 5f2aad00f4
Check extension and helper / check (push) Canceled after 0s
Publish YouTubeDL 1.4.5 and website on Gitea
2026-10-10 23:53:17 +03:00

21 lines
857 B
Python

"""Manage only this helper's per-user browser registrations."""
from pathlib import Path
from host.common import HOST_NAME
def unregister(root: Path):
import winreg
expected = str((root / ".runtime" / "native-host.json").resolve()).casefold()
removed = 0
for browser in (r"Google\Chrome", r"Microsoft\Edge", "Chromium"):
key = rf"Software\{browser}\NativeMessagingHosts\{HOST_NAME}"
try:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key) as handle:
current = winreg.QueryValueEx(handle, "")[0]
if isinstance(current, str) and str(Path(current).resolve()).casefold() == expected:
winreg.DeleteKey(winreg.HKEY_CURRENT_USER, key)
removed += 1
except FileNotFoundError:
continue
return {"removed": True, "registrations": removed}