From 00f5de1a3914f908fe274851c2e2ac41fa33e652 Mon Sep 17 00:00:00 2001 From: GhoulBoii Date: Wed, 20 Mar 2024 15:40:56 +0530 Subject: [PATCH] refactor: Using more verbose powershell --- setup.ps1 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/setup.ps1 b/setup.ps1 index f0517eb..4ffedf4 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -1,5 +1,3 @@ -$name = Read-Host -Prompt "Enter name of the firefox profile" - $addonlist = @" ublock-origin, bitwarden-password-manager, @@ -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 @@ -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