first commit

This commit is contained in:
Raven Scott
2026-02-12 03:27:05 -05:00
commit 90c7a4910e
38 changed files with 7466 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env node
/**
* Bundle Protomux + compact-encoding + b4a for the browser extension.
* Output: extension/protomux-bundle.js (IIFE, assigned to window.BridgeSwarmProtomux)
*/
const esbuild = require('esbuild');
const path = require('path');
const root = path.resolve(__dirname, '..');
const entry = path.join(root, 'extension', 'protomux-entry.cjs');
const outfile = path.join(root, 'extension', 'protomux-bundle.js');
esbuild
.build({
entryPoints: [entry],
bundle: true,
format: 'iife',
globalName: 'BridgeSwarmProtomux',
outfile,
platform: 'browser',
mainFields: ['browser', 'module', 'main'],
minify: false,
})
.then(() => console.log('Built', outfile))
.catch((err) => {
console.error(err);
process.exit(1);
});
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env node
'use strict';
/**
* Generates a new extension ID and updates manifest.json and com.bridgeswarm.json.
* Run on install so each copy of the template gets a unique ID (no overwrites).
*/
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const repoRoot = path.join(__dirname, '..');
const manifestPath = path.join(repoRoot, 'extension', 'manifest.json');
const nativeManifestPath = path.join(repoRoot, 'com.bridgeswarm.json');
// Generate RSA 2048-bit key pair
const { publicKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 2048,
publicKeyEncoding: { type: 'spki', format: 'der' },
privateKeyEncoding: { type: 'pkcs8', format: 'der' }
});
// Chrome extension ID: first 16 bytes of SHA256(publicKey), each byte -> 2 chars a-p
// (Chromium crx_id.py: HexToMPDecimal)
const hash = crypto.createHash('sha256').update(publicKey).digest();
const chromeId = Array.from(hash.slice(0, 16))
.map(b => String.fromCharCode(97 + (b >> 4)) + String.fromCharCode(97 + (b & 0x0f)))
.join('');
// Firefox ID: unique per install
const firefoxId = 'bridgeswarm-' + crypto.randomBytes(8).toString('hex') + '@example.org';
// Base64-encode public key for manifest
const keyBase64 = publicKey.toString('base64');
// Update extension manifest
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
manifest.key = keyBase64;
if (manifest.browser_specific_settings?.gecko) {
manifest.browser_specific_settings.gecko.id = firefoxId;
}
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
// Update native host manifest template
const nativeManifest = JSON.parse(fs.readFileSync(nativeManifestPath, 'utf8'));
nativeManifest.allowed_origins = ['chrome-extension://' + chromeId + '/'];
nativeManifest.allowed_extensions = [firefoxId];
fs.writeFileSync(nativeManifestPath, JSON.stringify(nativeManifest, null, 2) + '\n');
console.log('Generated extension ID:', chromeId, '(' + firefoxId + ')');
+13
View File
@@ -0,0 +1,13 @@
# Install only the extension (copy path, open browser). For full install use scripts/install.ps1.
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path
$ExtDir = (Resolve-Path (Join-Path $RepoRoot "extension")).Path
if (-not (Test-Path (Join-Path $ExtDir "manifest.json"))) { Write-Error "extension/manifest.json not found."; exit 1 }
Write-Host "Generating extension ID..."
node (Join-Path $ScriptDir "generate-extension-id.js")
Set-Clipboard -Value $ExtDir
$p = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe","${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe","${env:LocalAppData}\Google\Chrome\Application\chrome.exe" | Where-Object { Test-Path $_ } | Select-Object -First 1
if ($p) { Start-Process $p -ArgumentList "chrome://extensions" }
Write-Host "Extension path (clipboard): $ExtDir"
Write-Host "Open the extension page, click 'Load unpacked', paste the path."
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Install only the extension (copy path, open browser). For full install use scripts/install.sh.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
EXT_DIR="$REPO_ROOT/extension"
[[ ! -f "$EXT_DIR/manifest.json" ]] && echo "Error: extension/manifest.json not found." && exit 1
echo "Generating extension ID..."
node "$SCRIPT_DIR/generate-extension-id.js"
command -v pbcopy >/dev/null 2>&1 && echo "$EXT_DIR" | pbcopy
command -v xclip >/dev/null 2>&1 && echo -n "$EXT_DIR" | xclip -selection clipboard 2>/dev/null || true
command -v xsel >/dev/null 2>&1 && echo -n "$EXT_DIR" | xsel --clipboard 2>/dev/null || true
open_page() { local u="$1" a="$2"; [[ "$OSTYPE" == "darwin"* ]] && open -a "$a" "$u" 2>/dev/null && return 0; command -v xdg-open >/dev/null 2>&1 && xdg-open "$u" 2>/dev/null; }
open_page "chrome://extensions" "Google Chrome" || open_page "chrome://extensions" "Chromium" || open_page "chrome://extensions" "Microsoft Edge" || true
echo "Extension path (clipboard): $EXT_DIR"
echo "Open the extension page, click 'Load unpacked', paste the path."
+37
View File
@@ -0,0 +1,37 @@
# Install only the native messaging host (Windows). For full install use scripts/install.ps1.
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path
$HostDir = Join-Path $RepoRoot "native-host"
Set-Location $HostDir
Write-Host "Generating extension ID..."
node (Join-Path $ScriptDir "generate-extension-id.js")
Write-Host "Installing native-host dependencies..."
if (-not (Test-Path (Join-Path $HostDir "node_modules"))) {
npm install --no-fund --no-audit 2>$null
if ($LASTEXITCODE -ne 0) { npm install }
} else {
Write-Host " node_modules exists, skipping npm install"
}
$nodePath = (Get-Command node -ErrorAction SilentlyContinue).Source
$barePath = (Get-Command bare -ErrorAction SilentlyContinue).Source
if (-not $nodePath) { $nodePath = "node" }
if (-not $barePath) { $barePath = "bare" }
$batContent = "@echo off`r`nset `"DIR=%~dp0`"`r`n`"$nodePath`" `"$barePath`" `"%DIR%index.mjs`" %*"
Set-Content (Join-Path $HostDir "bridge-swarm-host.bat") -Value $batContent -Encoding ASCII
$HostPath = Join-Path $HostDir "bridge-swarm-host.bat"
$manifest = Get-Content (Join-Path $RepoRoot "com.bridgeswarm.json") -Raw | ConvertFrom-Json
$manifest.path = $HostPath
$manifestFile = Join-Path $env:LOCALAPPDATA "bridge-swarm\com.bridgeswarm.json"
New-Item -ItemType Directory -Path (Split-Path $manifestFile) -Force | Out-Null
$manifest | ConvertTo-Json -Depth 4 | Set-Content $manifestFile -Encoding UTF8
New-Item -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm" -Name "(Default)" -Value $manifestFile
New-Item -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.bridgeswarm" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Mozilla\NativeMessagingHosts\com.bridgeswarm" -Name "(Default)" -Value $manifestFile
Write-Host "Done. Manifest: $manifestFile"
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Install only the native messaging host (macOS/Linux). For full install use scripts/install.sh.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
HOST_DIR="$REPO_ROOT/native-host"
cd "$HOST_DIR"
echo "Generating extension ID..."
node "$SCRIPT_DIR/generate-extension-id.js"
echo "Installing native-host dependencies..."
if [[ ! -d "$HOST_DIR/node_modules" ]]; then
npm install --no-fund --no-audit 2>/dev/null || npm install
else
echo " node_modules exists, skipping npm install"
fi
BARE_PATH="$(which bare 2>/dev/null)" || true
[[ -z "$BARE_PATH" ]] && for c in /opt/homebrew/bin/bare /usr/local/bin/bare; do [[ -x "$c" ]] && BARE_PATH="$c" && break; done
NODE_PATH=""
if [[ -n "$BARE_PATH" ]]; then
BARE_DIR="${BARE_PATH%/*}"
for c in "$BARE_DIR/node" "$(which node 2>/dev/null)" /opt/homebrew/bin/node /usr/local/bin/node; do
[[ -x "$c" ]] && NODE_PATH="$c" && break
done
fi
[[ -z "$NODE_PATH" ]] && NODE_PATH="node"
[[ -z "$BARE_PATH" ]] && BARE_PATH="bare"
cat > "$HOST_DIR/bridge-swarm-host" << EOF
#!/usr/bin/env bash
DIR="\$(cd "\$(dirname "\$0")" && pwd)"
exec "$NODE_PATH" "$BARE_PATH" "\$DIR/index.mjs" "\$@"
EOF
chmod +x "$HOST_DIR/bridge-swarm-host"
HOST_PATH="$HOST_DIR/bridge-swarm-host"
CHROME_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
CHROMIUM_DIR="$HOME/.config/chromium/NativeMessagingHosts"
FIREFOX_DIR="$HOME/.mozilla/native-messaging-hosts"
[[ "$OSTYPE" == "darwin"* ]] && CHROME_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" && CHROMIUM_DIR="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" && FIREFOX_DIR="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
MANIFEST_NAME="com.bridgeswarm"
MANIFEST_CONTENT=$(sed "s|ABSOLUTE_PATH_TO_NATIVE_HOST|$HOST_PATH|g" "$REPO_ROOT/com.bridgeswarm.json")
for dir in "$CHROME_DIR" "$CHROMIUM_DIR" "$FIREFOX_DIR"; do
mkdir -p "$dir" 2>/dev/null && echo "$MANIFEST_CONTENT" > "$dir/${MANIFEST_NAME}.json" && echo "Wrote $dir/${MANIFEST_NAME}.json"
done
echo "Done. Wrapper: $NODE_PATH $BARE_PATH"
+96
View File
@@ -0,0 +1,96 @@
# Unified installer for BridgeSwarm (extension + native host).
# Run from anywhere: .\scripts\install.ps1 or cd bridge-swarm; .\scripts\install.ps1
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path
Write-Host "BridgeSwarm Install" -ForegroundColor Cyan
Write-Host "============================="
# Require Node.js
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Host "Error: Node.js is required. Install from https://nodejs.org and run this script again." -ForegroundColor Red
exit 1
}
# Generate unique extension ID (so each copy of the template gets its own ID)
Write-Host ""
Write-Host "0. Generating extension ID..."
node (Join-Path $ScriptDir "generate-extension-id.js")
# Ensure bare is available
if (-not (Get-Command bare -ErrorAction SilentlyContinue)) {
Write-Host "Installing Bare runtime (required for native host)..."
npm install -g bare 2>$null
if (-not (Get-Command bare -ErrorAction SilentlyContinue)) {
Write-Host "Warning: Could not install bare. Run: npm install -g bare" -ForegroundColor Yellow
}
}
# 1. Native host
Write-Host ""
Write-Host "1. Installing native host..."
$HostDir = Join-Path $RepoRoot "native-host"
Set-Location $HostDir
if (-not (Test-Path (Join-Path $HostDir "node_modules"))) {
npm install --no-fund --no-audit 2>$null
if ($LASTEXITCODE -ne 0) { npm install }
} else {
Write-Host " node_modules exists, skipping npm install"
}
# Windows: use .bat that runs bare; Chrome may have limited PATH so use full path if we can find it
$bareCmd = Get-Command bare -ErrorAction SilentlyContinue
$nodeCmd = Get-Command node -ErrorAction SilentlyContinue
$nodePath = if ($nodeCmd) { $nodeCmd.Source } else { "node" }
$barePath = if ($bareCmd) { $bareCmd.Source } else { "bare" }
$batContent = "@echo off`r`nset `"DIR=%~dp0`"`r`n`"$nodePath`" `"$barePath`" `"%DIR%index.mjs`" %*"
$batContent | Set-Content (Join-Path $HostDir "bridge-swarm-host.bat") -Encoding ASCII
$HostPath = Join-Path $HostDir "bridge-swarm-host.bat"
$manifestPath = Join-Path $RepoRoot "com.bridgeswarm.json"
$manifest = Get-Content $manifestPath -Raw | ConvertFrom-Json
$manifest.path = $HostPath
$manifestFile = Join-Path $env:LOCALAPPDATA "bridge-swarm\com.bridgeswarm.json"
$manifestDir = Split-Path $manifestFile
if (-not (Test-Path $manifestDir)) { New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null }
$manifest | ConvertTo-Json -Depth 4 | Set-Content $manifestFile -Encoding UTF8
$chromeKey = "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm"
New-Item -Path $chromeKey -Force | Out-Null
Set-ItemProperty -Path $chromeKey -Name "(Default)" -Value $manifestFile
$ffKey = "HKCU:\Software\Mozilla\NativeMessagingHosts\com.bridgeswarm"
New-Item -Path $ffKey -Force | Out-Null
Set-ItemProperty -Path $ffKey -Name "(Default)" -Value $manifestFile
Write-Host " Native host manifest: $manifestFile"
# 2. Extension
Write-Host ""
Write-Host "2. Preparing extension..."
$ExtDir = (Resolve-Path (Join-Path $RepoRoot "extension")).Path
if (-not (Test-Path (Join-Path $ExtDir "manifest.json"))) {
Write-Host "Error: extension/manifest.json not found." -ForegroundColor Red
exit 1
}
Set-Clipboard -Value $ExtDir
$chromePaths = @(
"${env:ProgramFiles}\Google\Chrome\Application\chrome.exe",
"${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe",
"${env:LocalAppData}\Google\Chrome\Application\chrome.exe"
)
foreach ($p in $chromePaths) {
if (Test-Path $p) {
Start-Process $p -ArgumentList "chrome://extensions"
break
}
}
Write-Host ""
Write-Host "Done." -ForegroundColor Green
Write-Host ""
Write-Host "Next step: In the browser tab that opened, click 'Load unpacked' and paste this path:"
Write-Host " $ExtDir"
Write-Host "(Path is in your clipboard.) Then restart the browser."
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env bash
# Unified installer for BridgeSwarm (extension + native host).
# Run from anywhere: ./scripts/install.sh or cd bridge-swarm && ./scripts/install.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"
echo "BridgeSwarm Install"
echo "============================="
# Require Node.js
if ! command -v node >/dev/null 2>&1; then
echo "Error: Node.js is required. Install from https://nodejs.org and run this script again."
exit 1
fi
# Generate unique extension ID (so each copy of the template gets its own ID)
echo ""
echo "0. Generating extension ID..."
node "$SCRIPT_DIR/generate-extension-id.js"
# Ensure bare is available (required for native host)
if ! command -v bare >/dev/null 2>&1; then
echo "Installing Bare runtime (required for native host)..."
if npm install -g bare 2>/dev/null; then
echo "Bare installed."
else
echo "Warning: Could not install bare. Run: npm install -g bare"
echo "Continuing; native host may not work until bare is installed."
fi
fi
# 1. Native host
echo ""
echo "1. Installing native host..."
HOST_DIR="$REPO_ROOT/native-host"
cd "$HOST_DIR"
if [[ ! -d "$HOST_DIR/node_modules" ]]; then
npm install --no-fund --no-audit 2>/dev/null || npm install
else
echo " node_modules exists, skipping npm install"
fi
BARE_PATH="$(command -v bare 2>/dev/null)" || true
if [[ -z "$BARE_PATH" ]]; then
for c in /opt/homebrew/bin/bare /usr/local/bin/bare; do
[[ -x "$c" ]] && BARE_PATH="$c" && break
done
fi
NODE_PATH=""
if [[ -n "$BARE_PATH" ]]; then
BARE_DIR="${BARE_PATH%/*}"
for c in "$BARE_DIR/node" "$(command -v node 2>/dev/null)" /opt/homebrew/bin/node /usr/local/bin/node; do
[[ -x "$c" ]] && NODE_PATH="$c" && break
done
fi
if [[ -z "$NODE_PATH" ]] || [[ -z "$BARE_PATH" ]]; then
echo "Warning: node or bare not found in standard locations. Wrapper may fail when run by Chrome."
NODE_PATH="node"
BARE_PATH="bare"
fi
cat > "$HOST_DIR/bridge-swarm-host" << EOF
#!/usr/bin/env bash
DIR="\$(cd "\$(dirname "\$0")" && pwd)"
exec "$NODE_PATH" "$BARE_PATH" "\$DIR/index.mjs" "\$@"
EOF
chmod +x "$HOST_DIR/bridge-swarm-host"
HOST_PATH="$HOST_DIR/bridge-swarm-host"
CHROME_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
CHROMIUM_DIR="$HOME/.config/chromium/NativeMessagingHosts"
FIREFOX_DIR="$HOME/.mozilla/native-messaging-hosts"
if [[ "$OSTYPE" == "darwin"* ]]; then
CHROME_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
CHROMIUM_DIR="$HOME/Library/Application Support/Chromium/NativeMessagingHosts"
FIREFOX_DIR="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
fi
MANIFEST_NAME="com.bridgeswarm"
MANIFEST_CONTENT=$(sed "s|ABSOLUTE_PATH_TO_NATIVE_HOST|$HOST_PATH|g" "$REPO_ROOT/com.bridgeswarm.json")
for dir in "$CHROME_DIR" "$CHROMIUM_DIR" "$FIREFOX_DIR"; do
mkdir -p "$dir" 2>/dev/null && echo "$MANIFEST_CONTENT" > "$dir/${MANIFEST_NAME}.json" && echo " Native host manifest: $dir"
done
# 2. Extension
echo ""
echo "2. Preparing extension..."
EXT_DIR="$REPO_ROOT/extension"
if [[ ! -f "$EXT_DIR/manifest.json" ]]; then
echo "Error: extension/manifest.json not found."
exit 1
fi
if command -v pbcopy >/dev/null 2>&1; then
echo "$EXT_DIR" | pbcopy
elif command -v xclip >/dev/null 2>&1; then
echo -n "$EXT_DIR" | xclip -selection clipboard 2>/dev/null || true
elif command -v xsel >/dev/null 2>&1; then
echo -n "$EXT_DIR" | xsel --clipboard 2>/dev/null || true
fi
open_page() {
local url="$1" app="$2"
if [[ "$OSTYPE" == "darwin"* ]]; then
open -a "$app" "$url" 2>/dev/null && return 0
fi
command -v xdg-open >/dev/null 2>&1 && xdg-open "$url" 2>/dev/null && return 0
return 1
}
open_page "chrome://extensions" "Google Chrome" || \
open_page "chrome://extensions" "Chromium" || \
open_page "chrome://extensions" "Microsoft Edge" || true
echo ""
echo "Done."
echo ""
echo "Next step: In the browser tab that opened, click 'Load unpacked' and paste this path:"
echo " $EXT_DIR"
echo "(Path is in your clipboard.) Then restart the browser."
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env node
'use strict';
var path = require('path');
var spawn = require('child_process').spawn;
var isWin = process.platform === 'win32';
var script = path.join(__dirname, isWin ? 'install.ps1' : 'install.sh');
var child = spawn(isWin ? 'powershell' : '/bin/sh', isWin ? ['-ExecutionPolicy', 'Bypass', '-File', script] : [script], {
stdio: 'inherit',
cwd: path.join(__dirname, '..'),
});
child.on('exit', function (code, sig) {
process.exit(code !== null ? code : sig ? 1 : 0);
});
@@ -0,0 +1,11 @@
# Update native host manifest with your Chrome extension ID (fix "Access forbidden").
# Usage: .\scripts\update-native-manifest-extension-id.ps1 YOUR_EXTENSION_ID
param([Parameter(Mandatory=$true)] [string] $ExtensionId)
$ExtensionId = $ExtensionId -replace '^chrome-extension://', '' -replace '/$', ''
$Origin = "chrome-extension://$ExtensionId/"
$manifestFile = (Get-ItemProperty -Path "HKCU:\Software\Google\Chrome\NativeMessagingHosts\com.bridgeswarm" -ErrorAction SilentlyContinue).'(Default)'
if (-not $manifestFile -or -not (Test-Path $manifestFile)) { Write-Host "Run scripts/install.ps1 first."; exit 1 }
$m = Get-Content $manifestFile -Raw | ConvertFrom-Json
$m.allowed_origins = @($Origin)
$m | ConvertTo-Json -Depth 4 | Set-Content $manifestFile -Encoding UTF8
Write-Host "Updated $manifestFile. Restart Chrome."
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Update native host manifest with your Chrome extension ID (fix "Access forbidden").
# Usage: ./scripts/update-native-manifest-extension-id.sh YOUR_EXTENSION_ID
set -e
[[ -z "$1" ]] && echo "Usage: $0 YOUR_CHROME_EXTENSION_ID (from chrome://extensions)" && exit 1
EXT_ID="${1#chrome-extension://}"; EXT_ID="${EXT_ID%/}"
ORIGIN="chrome-extension://${EXT_ID}/"
CHROME_DIR="$HOME/.config/google-chrome/NativeMessagingHosts"
CHROMIUM_DIR="$HOME/.config/chromium/NativeMessagingHosts"
[[ "$OSTYPE" == "darwin"* ]] && CHROME_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" && CHROMIUM_DIR="$HOME/Library/Application Support/Chromium/NativeMessagingHosts"
MANIFEST_NAME="com.bridgeswarm"
updated=0
for dir in "$CHROME_DIR" "$CHROMIUM_DIR"; do
f="$dir/${MANIFEST_NAME}.json"
[[ ! -f "$f" ]] && continue
if command -v node >/dev/null 2>&1; then
node -e "const fs=require('fs');const j=JSON.parse(fs.readFileSync('$f','utf8'));j.allowed_origins=['$ORIGIN'];fs.writeFileSync('$f',JSON.stringify(j,null,2));"
else
sed -i.bak "s|\"chrome-extension://[^\"]*/\"|\"$ORIGIN\"|g" "$f" && rm -f "${f}.bak"
fi
echo "Updated $f"
updated=1
done
[[ $updated -eq 0 ]] && echo "No manifest found. Run scripts/install.sh first." && exit 1
echo "Done. Restart Chrome."