Sync working tree before initial Gitea push
- File reorg: popup/options/bulk-check moved to src/ subdirs - Shared modules: src/shared/id-extract.js, src/options/options-shared.js - Host updates: rcjav-host.py + register/install scripts - .gitignore expanded
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"discord_webhook_url": "https://discord.com/api/webhooks/1507933272158507200/TEDqaLNBQn4dlSsG5kC2HP9IbTPg0trVWcy1WA46TdaLfZ1waMV82nTcNqVsfOY1Sw6u",
|
||||
"pc_label": "001x100"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"allowed_extension_ids": {
|
||||
"rclone-jav": "dklpnjdfcoalaognbgbjoilklfjlnpnj",
|
||||
"tabvault": "fdeddmkchldohogpogpahnkibifciflp"
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
"path": "D:\\DEV\\Extensions\\Production\\rclone-jav\\host\\rcjav-host.bat",
|
||||
"type": "stdio",
|
||||
"allowed_origins": [
|
||||
"chrome-extension://afbnfamppannbmhgphbbgdkmilijfagp/"
|
||||
"chrome-extension://dklpnjdfcoalaognbgbjoilklfjlnpnj/",
|
||||
"chrome-extension://fdeddmkchldohogpogpahnkibifciflp/"
|
||||
]
|
||||
}
|
||||
}
|
||||
+54
-22
@@ -1,15 +1,15 @@
|
||||
# install-host.ps1
|
||||
# Registers rclonex native-messaging host so Brave can launch it.
|
||||
#
|
||||
# Usage: .\install-host.ps1 -ExtensionId <id-from-brave://extensions>
|
||||
# Usage: .\install-host.ps1
|
||||
# Optional: .\install-host.ps1 -ExtensionId <id-from-brave://extensions>
|
||||
#
|
||||
# Writes manifest to host\com.rcjav.host.json with the correct path + extension ID baked in,
|
||||
# Writes manifest to host\com.rcjav.host.json with the correct path + extension ID allowed,
|
||||
# then registers it in HKLM (requires admin - script self-elevates if needed) AND HKCU.
|
||||
# HKLM is required on some Brave installs; HKCU alone is not always honored.
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ExtensionId
|
||||
[string]$ExtensionId = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -19,30 +19,62 @@ $batPath = Join-Path $hostDir "rcjav-host.bat"
|
||||
if (-not (Test-Path $batPath)) { throw "Host bat not found: $batPath" }
|
||||
|
||||
$manifestPath = Join-Path $hostDir "com.rcjav.host.json"
|
||||
$template = Join-Path $hostDir "com.rcjav.host.json.template"
|
||||
if (-not (Test-Path $template)) { throw "Template not found: $template" }
|
||||
$allowlistPath = Join-Path $hostDir "allowed-extension-ids.json"
|
||||
|
||||
$content = Get-Content $template -Raw
|
||||
$content = $content.Replace("__HOST_BAT__", ($batPath -replace "\\", "\\"))
|
||||
$content = $content.Replace("__EXTENSION_ID__", $ExtensionId)
|
||||
# Self-elevate before writing the manifest or HKLM registry entries. Some
|
||||
# installs keep the host folder under admin-owned permissions.
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
|
||||
[Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "Not running as admin - relaunching elevated..."
|
||||
$args = @(
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass",
|
||||
"-File", $PSCommandPath
|
||||
)
|
||||
if ($ExtensionId) { $args += @("-ExtensionId", $ExtensionId) }
|
||||
Start-Process pwsh -Verb RunAs -ArgumentList $args
|
||||
exit
|
||||
}
|
||||
|
||||
$extensionIds = @()
|
||||
if (Test-Path $allowlistPath) {
|
||||
try {
|
||||
$allowlist = Get-Content $allowlistPath -Raw | ConvertFrom-Json
|
||||
if ($allowlist.allowed_extension_ids) {
|
||||
$props = $allowlist.allowed_extension_ids.PSObject.Properties
|
||||
foreach ($prop in $props) {
|
||||
$id = [string]$prop.Value
|
||||
if ($id -match '^[a-p]{32}$' -and $extensionIds -notcontains $id) {
|
||||
$extensionIds += $id
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
throw "Failed to read $allowlistPath`: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
if ($ExtensionId) {
|
||||
if ($ExtensionId -notmatch '^[a-p]{32}$') { throw "Invalid extension ID: $ExtensionId" }
|
||||
if ($extensionIds -notcontains $ExtensionId) { $extensionIds += $ExtensionId }
|
||||
}
|
||||
if ($extensionIds.Count -eq 0) {
|
||||
throw "No extension IDs configured. Add IDs to $allowlistPath or pass -ExtensionId."
|
||||
}
|
||||
$allowedOrigins = @($extensionIds | ForEach-Object { "chrome-extension://$_/" })
|
||||
|
||||
$manifest = [ordered]@{
|
||||
name = "com.rcjav.host"
|
||||
description = "rclonex native messaging host (rc-jav bridge)"
|
||||
path = $batPath
|
||||
type = "stdio"
|
||||
allowed_origins = @($allowedOrigins)
|
||||
}
|
||||
$content = $manifest | ConvertTo-Json -Depth 4
|
||||
|
||||
# UTF-8 WITHOUT BOM - Chrome/Brave rejects manifests with a BOM.
|
||||
[System.IO.File]::WriteAllText($manifestPath, $content, [System.Text.UTF8Encoding]::new($false))
|
||||
Write-Host "Manifest written: $manifestPath"
|
||||
|
||||
# Self-elevate for HKLM if not already admin.
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
|
||||
[Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "Not running as admin - relaunching elevated to write HKLM..."
|
||||
Start-Process pwsh -Verb RunAs -ArgumentList @(
|
||||
"-NoProfile", "-ExecutionPolicy", "Bypass",
|
||||
"-File", $PSCommandPath,
|
||||
"-ExtensionId", $ExtensionId
|
||||
)
|
||||
exit
|
||||
}
|
||||
|
||||
# Register in HKLM - required on some Brave installs.
|
||||
$keys = @(
|
||||
'HKLM:\Software\BraveSoftware\Brave-Browser\NativeMessagingHosts\com.rcjav.host',
|
||||
|
||||
+8
-4
@@ -1,8 +1,12 @@
|
||||
@echo off
|
||||
REM Portable: uses Windows py launcher if present, falls back to python on PATH.
|
||||
REM Stderr redirected to log file so it can't pollute stdout (native messaging is binary).
|
||||
REM Portable: use python on PATH. Avoid py.exe as an extra native-messaging
|
||||
REM stdio hop; Chrome/Brave can be picky about inherited handles.
|
||||
REM Stderr capture lives INSIDE rcjav-host.py now (shared-access append via
|
||||
REM os.open + os.dup2). The previous `2>>` redirection here used cmd.exe's
|
||||
REM exclusive-write file handle, which caused SHARING VIOLATION races when
|
||||
REM two host processes spawned near-simultaneously — surfacing to the
|
||||
REM extension as "Error when communicating with the native messaging host."
|
||||
setlocal
|
||||
set "PYBIN=python"
|
||||
where py >nul 2>&1 && set "PYBIN=py"
|
||||
if not exist "%~dp0logs" mkdir "%~dp0logs"
|
||||
"%PYBIN%" -u "%~dp0rcjav-host.py" 2>>"%~dp0logs\rcjav-host-stderr.log"
|
||||
"%PYBIN%" -u "%~dp0rcjav-host.py"
|
||||
|
||||
+790
-61
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,10 @@
|
||||
@echo off
|
||||
REM Double-click this to register the native messaging host with Brave.
|
||||
REM Prompts for the extension ID, then runs install-host.ps1.
|
||||
REM Reads allowed extension IDs from allowed-extension-ids.json, then runs install-host.ps1.
|
||||
|
||||
setlocal
|
||||
set /p EXT_ID="Paste the rclone-jav extension ID from brave://extensions: "
|
||||
|
||||
if "%EXT_ID%"=="" (
|
||||
echo No ID entered. Aborting.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0install-host.ps1" -ExtensionId "%EXT_ID%"
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0install-host.ps1"
|
||||
echo.
|
||||
echo Done. Press any key to close.
|
||||
pause >nul
|
||||
|
||||
Reference in New Issue
Block a user