Browser Extension Packages
Chrome
chocolateyInstall.ps1
$bits = Get-ProcessorBits
$packageName = 'oblockorigin-chrome'
$extensionID = 'cjpalhdlnbpafiamejdnhcphjbkeiagm'
if ($bits -eq 64)
{
if (Test-Path -Path "HKLM:\SOFTWARE\Wow6432node\Google\Chrome\Extensions\$extensionID")
{
Write-Host "Extension already installed." -foreground "magenta" –backgroundcolor "blue"
} else {
New-Item -Force -Path "HKLM:\SOFTWARE\Wow6432node\Google\Chrome\Extensions\$extensionID" | out-null
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432node\Google\Chrome\Extensions\$extensionID\" -Name "update_url" -Value "https://clients2.google.com/service/update2/crx" | out-null
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432node\Google\Chrome\Extensions\$extensionID\" -Name "ChocolateyPackageName" -Value "$packageName" | out-null
}
} else {
New-Item -Force -Path "HKLM:\SOFTWARE\Google\Chrome\Extensions\$extensionID" | out-null
New-ItemProperty -Path "HKLM:\SOFTWARE\Google\Chrome\Extensions\$extensionID\" -Name "update_url" -Value "https://clients2.google.com/service/update2/crx" | out-null
}
chocolateyUninstall.ps1
$bits = Get-ProcessorBits
$packageName = 'ublockorigin-chrome'
$extensionID = 'cjpalhdlnbpafiamejdnhcphjbkeiagm'
if ($bits -eq 64) {
Remove-Item "HKLM:\SOFTWARE\Wow6432node\Google\Chrome\Extensions\$extensionID" -Force -ErrorAction SilentlyContinue | out-null
}else{
Remove-Item "HKLM:\SOFTWARE\Google\Chrome\Extensions\$extensionID" -Force -ErrorAction SilentlyContinue | out-null
}
Firefox
Mag nicht mehr der aktuellste Weg sein, Firefox speichert Extensions eher im Profil statt im Programmordner, wie es das Script hier tut. C:\Program Files\Mozilla Firefox\browser\extensions würde ohne dieses Script nicht angelegt sein.
Gibt aber unter HKLM\SOFTWARE\WOW6432Node\Mozilla\Firefox\TaskBarIDs auch nur den Programmpfad und nicht den Profilpfad. Der Profilpfad aus about:profiles steht nicht mal eben so einfach in der Registry zum auslesen.
chocolateyInstall.ps1
$packageName = 'adblockplus-firefox'
$url = 'https://addons.mozilla.org/firefox/downloads/latest/1865/addon-1865-latest.xpi'
$extensionID = "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"
#xpi download, extract like zip files, open manifest.json, Ctrl+F, id (may/should also be an email-adress these days)
if(test-path 'hklm:\SOFTWARE\Mozilla\Firefox\TaskBarIDs'){
$installDir = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Firefox\TaskBarIDs | Select-Object -ExpandProperty Property
}
if(test-path 'hklm:\SOFTWARE\Wow6432Node\Mozilla\Firefox\TaskBarIDs'){
$installDir = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Firefox\TaskBarIDs | Select-Object -ExpandProperty Property
}
$browserFolder = Join-Path $installDir "browser"
$extensionsFolder = Join-Path $browserFolder "extensions"
$extFolder = Join-Path $extensionsFolder "$extensionID"
if (!(Test-Path $extFolder)) {
New-Item -Force -ItemType directory -Path $extFolder
Install-ChocolateyZipPackage "$packageName" "$url" "$extFolder"
}
else {
Write-Host "$packageName already exists"
}
chocolateyUninstall.ps1
$extensionID = "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"
if(test-path 'hklm:\SOFTWARE\Mozilla\Firefox\TaskBarIDs'){
$installDir = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Firefox\TaskBarIDs | Select-Object -ExpandProperty Property
}
if(test-path 'hklm:\SOFTWARE\Wow6432Node\Mozilla\Firefox\TaskBarIDs'){
$installDir = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Firefox\TaskBarIDs | Select-Object -ExpandProperty Property
}
$browserFolder = Join-Path $installDir "browser"
$extensionsFolder = Join-Path $browserFolder "extensions"
$extFolder = Join-Path $extensionsFolder "$extensionID"
Remove-Item "$extFolder" -Force -Recurse -ErrorAction SilentlyContinue