Skip to content

Commit

Permalink
refactor: Using more verbose powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
GhoulBoii committed Mar 20, 2024
1 parent 4068e2a commit 00f5de1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions setup.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$name = Read-Host -Prompt "Enter name of the firefox profile"

$addonlist = @"
ublock-origin,
bitwarden-password-manager,
Expand All @@ -10,16 +8,19 @@ windscribe,
violentmonkey
"@

echo "Creating Profile"
Start-Process "firefox" -ArgumentList "-CreateProfile $name"
Write-Host "Enter name of the firefox profile: " -ForegroundColor Green -NoNewline
$name = Read-Host

Write-Host "Creating Profile" -ForegroundColor Green
Start-Process "firefox" -ArgumentList "-CreateProfile $name"
# Firefox does not update profile.ini fast enough so sleep is needed
Start-Sleep 1
$folder = (Get-Content "$env:APPDATA\Mozilla\Firefox\profiles.ini" | Select-String -Pattern "Path=.*$name$" | ForEach-Object { $_ -replace 'Path=', '' })
$dir = Join-Path -Path "$env:APPDATA/Mozilla/Firefox" "$folder"
cd $dir
echo "Profile Creation Finished"
Set-Location -Path "$dir"
Write-Host "Profile Creation Finished" -ForegroundColor Green

echo "Initialising Git Repo"
Write-Host "Initialising Git Repo" -ForegroundColor Green
git init
git remote add origin https://github.com/ghoulboii/firefox
git fetch
Expand All @@ -28,22 +29,21 @@ git submodule update --init --recursive --remote
robocopy userjs . user.js prefsCleaner.bat updater.bat
robocopy VerticalFox\windows\ chrome
robocopy VerticalFox\sidebery\ sidebery
echo "Git Repo Initialised"

Write-Host "Git Repo Initialised" -ForegroundColor Green

echo "Downloading Addons"
Write-Host "Downloading Addons" -ForegroundColor Green
$addontmp = New-Item -ItemType Directory -Path "$env:TEMP\addon" -Force
$mozillaurl = "https://addons.mozilla.org"
$addonlist -split ',' | ForEach-Object {
$addon = $_.Trim()
echo "Installing $addon"
Write-Host "Installing $addon" -ForegroundColor Green
$addonurl = (Invoke-WebRequest -Uri "$mozillaurl/en-US/firefox/addon/$addon/" -UseBasicParsing).Content | Select-String -Pattern "$mozillaurl/firefox/downloads/file/[^`"]*" | Select-Object -ExpandProperty Matches | ForEach-Object { $_.Value }
$file = $addonurl -split '/' | Select-Object -Last 1
Invoke-WebRequest -Uri $addonurl -OutFile "$addontmp\$file"
Expand-Archive -Path "$addontmp\$file" -DestinationPath "$addontmp\${file}folder" -Force
$id = (Select-String -Path "$addontmp/${file}folder/manifest.json" -Pattern '"id"' -Raw | ForEach-Object { $_ -replace '\s*"id":\s*"([^"]*)"', '$1' }).Trim(',')
New-Item -ItemType Directory -Path "$dir\extensions" -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path "$dir\extensions" -ErrorAction SilentlyContinue > $null
Move-Item -Path "$addontmp\$file" -Destination "$dir\extensions\$id.xpi" -Force
}
echo "Addons Installed"
Write-Host "Addons Installed" -ForegroundColor Green

0 comments on commit 00f5de1

Please sign in to comment.