33 lines
1.6 KiB
PowerShell
33 lines
1.6 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[ValidatePattern('^[a-p]{32}$')]
|
|
[string]$ExtensionId,
|
|
[string]$ArchivePath = "$env:USERPROFILE\ChromeHistoryArchive"
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$source = Join-Path $root 'native-host'
|
|
$target = Join-Path $env:LOCALAPPDATA 'LocalHistoryArchive'
|
|
|
|
if (-not (Get-Command py -ErrorAction SilentlyContinue)) {
|
|
throw 'Python 3 ni nameščen. Namesti ga z https://www.python.org/downloads/windows/ in označi možnost Add python.exe to PATH.'
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $target, $ArchivePath | Out-Null
|
|
Copy-Item "$source\history_archive_host.py" $target -Force
|
|
Copy-Item "$source\history_archive_host.bat" $target -Force
|
|
|
|
$manifest = (Get-Content "$source\si.komelt.local_history_archive.json.template" -Raw).Replace('C:\\LOCAL_HISTORY_ARCHIVE', ($target -replace '\\', '\\')).Replace('YOUR_EXTENSION_ID', $ExtensionId)
|
|
$manifestPath = Join-Path $target 'si.komelt.local_history_archive.json'
|
|
Set-Content -Path $manifestPath -Value $manifest -Encoding UTF8
|
|
|
|
[Environment]::SetEnvironmentVariable('LOCAL_HISTORY_ARCHIVE_DIR', $ArchivePath, 'User')
|
|
$regPath = 'HKCU:\Software\Google\Chrome\NativeMessagingHosts\si.komelt.local_history_archive'
|
|
New-Item -Path $regPath -Force | Out-Null
|
|
New-ItemProperty -Path $regPath -Name '(Default)' -Value $manifestPath -PropertyType String -Force | Out-Null
|
|
|
|
Write-Host "Nameščeno. Arhiv bo v: $ArchivePath\history.sqlite3"
|
|
Write-Host 'Zapri in znova odpri Chrome, nato obišči poljubno stran za preizkus.'
|