Last active
March 9, 2025 13:59
-
-
Save go2tom42/82c900c5599f4cf0b03b13bea0170ecc to your computer and use it in GitHub Desktop.
Updates my firefox theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Update-FFTheme { | |
Param( | |
[parameter(Mandatory = $false)] | |
[switch] $reset | |
) | |
<# | |
.SYNOPSIS | |
Install and updates Firefox to a custum Theme. | |
.DESCRIPTION | |
Install and updates Firefox to a custum Theme. | |
It closes and reopens Firefox | |
It downloads 3 files from github | |
"-reset" deletes current Chrome folder | |
.EXAMPLE | |
Update-FFTheme | |
Update-FFTheme -reset | |
.NOTES | |
Name: Update-FFTheme | |
Author: tom42 | |
Version: 0.0.2 | |
DateCreated: 2024 | |
DateModified: 2025 | |
.Link | |
https://github.com/go2tom42/Firefox-Mod-Blur-override | |
#> | |
BEGIN { | |
function Read-iniFile { | |
<# | |
.SYNOPSIS | |
Convert ini file to hash table, use Write-IniFile write file | |
.DESCRIPTION | |
Convert ini file to hash table, use Write-IniFile write file | |
.PARAMETER file | |
Full path to .ini file | |
.EXAMPLE | |
$bob = Read-iniFile "C:\WORK\somefile.ini" | |
.NOTES | |
Name: Read-iniFile | |
Author: tom42 | |
Version: 0.0.1 | |
DateCreated: 2024 | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $false)] | |
[string]$file | |
) | |
BEGIN { | |
$done = $false | |
if(!$file) { | |
Get-Help $MyInvocation.MyCommand | |
$done = $true | |
return | |
} | |
$ini = @{} | |
} | |
PROCESS { | |
if ($done) { return } | |
switch -regex -file $file { | |
"^\[(.+)\]$" { | |
$section = $matches[1].Trim() | |
$ini[$section] = @{} | |
} | |
"^\s*([^#].+?)\s*=\s*(.*)" { | |
$name, $value = $matches[1..2] | |
# skip comments that start with semicolon: | |
if (!($name.StartsWith(";"))) { | |
$ini[$section][$name] = $value.Trim() | |
} | |
} | |
} | |
$ini | |
} | |
END { | |
if ($done) { return } | |
#Used for cleanup. This code runs one time after all of the items specified via pipeline input are processed. | |
} | |
} | |
function Get-File() { | |
<# | |
.SYNOPSIS | |
Downloads files requiring Basic Authorization | |
.DESCRIPTION | |
Downloads files requiring Basic Authorization | |
.PARAMETER URL | |
URL to file | |
.PARAMETER Path | |
Path to save file | |
.PARAMETER User | |
Username | |
.PARAMETER Pass | |
Password | |
.EXAMPLE | |
PS C:\> Get-BAFile 'https://remotely.tom42.pw/Content/Remotely_Installer.exe' './Remotely_Installer.exe' 'tom42' '1tardis1' | |
Downloads .ps1 and runs it as admin | |
.EXAMPLE | |
PS C:\> Get-BAFile -URL 'https://remotely.tom42.pw/Content/Remotely_Installer.exe' -PATH './Remotely_Installer.exe' -USER 'tom42' -PASS '1tardis1' | |
Downloads .ps1 and runs it as admin | |
#> | |
[CmdletBinding()] | |
param( | |
[parameter(Mandatory = $false)] | |
[string] | |
$URL, | |
[parameter(Mandatory = $false)] | |
[string] | |
$PATH = "$((Get-Location).Path)", | |
[parameter(Mandatory = $false)] | |
[string] | |
$Filename = "NA", | |
[parameter(Mandatory = $false)] | |
[string] | |
$USER = "NA", | |
[parameter(Mandatory = $false)] | |
[string] | |
$PASS | |
) | |
BEGIN { | |
$done = $false | |
if(!$URL) { | |
Get-Help $MyInvocation.MyCommand | |
$done = $true | |
return | |
} | |
#Used for prep. This code runs one time prior to processing items specified via pipeline input. | |
} | |
PROCESS { | |
if ($done) { return } | |
if ($user -ieq "NA") { | |
if (Confirm-URL $URL) { | |
if ($Filename -ieq "NA") { | |
$Response = Invoke-WebRequest $Url -Verbose | |
$downloadFileName = $($Response.Headers.'Content-Disposition'.Split('=',2)[-1]).Trim('"') | |
} else { | |
$Response = Invoke-WebRequest $Url -Verbose | |
$downloadFileName = $Filename | |
} | |
$path = Join-Path $PATH $downloadFileName | |
[IO.File]::WriteAllBytes($path, $Response.Content) | |
Remove-Variable Response -Force | |
[GC]::Collect() | |
} else { | |
write-host 'NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL ' -f 'white' -b 'red' -n; write-host ([char]0xA0) | |
Pause | |
} | |
} else { | |
if (Confirm-URL $URL) { | |
if ($Filename -ieq "NA") { | |
$downloadFileName = (Invoke-WebRequest -Method Head "$url").BaseResponse.RequestMessage.RequestUri.Segments[-1] | |
} else { | |
$downloadFileName = $Filename | |
} | |
$path = Join-Path $PATH $downloadFileName | |
$WebClient = New-Object System.Net.WebClient; | |
$WebClient.Credentials = New-Object System.Net.Networkcredential($user, $pass) | |
$WebClient.DownloadFile($url, $path) | |
} else { | |
write-host 'NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL - NOT VALID URL ' -f 'white' -b 'red' -n; write-host ([char]0xA0) | |
Pause | |
} | |
} | |
} | |
END { | |
if ($done) { return } | |
#Used for cleanup. This code runs one time after all of the items specified via pipeline input are processed. | |
} | |
} | |
function Confirm-URL { | |
<# | |
.SYNOPSIS | |
Check if string is a URL format, can also verify if URL active | |
.DESCRIPTION | |
Check if string is a URL format, can also verify if URL active | |
.PARAMETER URL | |
URL to check | |
.PARAMETER verify | |
Verifiy URL is active | |
.EXAMPLE | |
Confirm-URL -URL "https://google.com" -verify | |
.NOTES | |
Name: Confirm-URL | |
Author: tom42 | |
Version: 0.0.1 | |
DateCreated: 2024 | |
#> | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $false)] | |
[string]$URL, | |
[Parameter(Mandatory = $false)] | |
[switch]$verify | |
) | |
BEGIN { | |
$done = $false | |
if(!$URL) { | |
Get-Help $MyInvocation.MyCommand | |
$done = $true | |
return | |
} | |
$address = $URL -as [System.URI] | |
} | |
PROCESS { | |
if ($done) { return } | |
if ($verify) { | |
if ($null -ne $address.AbsoluteURI -and $address.Scheme -match '[http|https]') { | |
If (((Invoke-WebRequest -uri "$URL" -method head -SkipHttpErrorCheck).StatusCode) -eq "200") { | |
Return $true | |
} else { | |
Return $false | |
} | |
} | |
} else { | |
If ($null -ne $address.AbsoluteURI -and $address.Scheme -match '[http|https]') { | |
Return $true | |
} else { | |
Return $false | |
} | |
} | |
} | |
END { | |
if ($done) { return } | |
#Used for cleanup. This code runs one time after all of the items specified via pipeline input are processed. | |
} | |
} | |
$ver = (get-ItemProperty -Path "HKLM:\Software\Mozilla\Mozilla Firefox").CurrentVersion | |
$ffEXE = (get-ItemProperty -Path "HKLM:\Software\Mozilla\Mozilla Firefox\$ver\Main").PathToExe | |
$FFini = Read-iniFile "$env:APPDATA\Mozilla\Firefox\profiles.ini" | |
$FFProfile = $FFini.Profile0.Path | |
$ffEXE = get-item $ffEXE | |
$FFChromePath = "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))\chrome" | |
if (-not (Test-Path $FFChromePath)) { | |
New-Item -Path "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))" -Name "chrome" -ItemType Directory -Force | |
} | |
Get-Process | Where-Object {$_.Path -like "*$ffEXE*"} | Stop-Process | |
Start-Sleep -Seconds 5 | |
if ($reset) { | |
Remove-Item $FFChromePath -Force -Recurse | |
Start-Sleep -Seconds 1 | |
New-Item $FFChromePath -ItemType "directory" | |
} | |
$knownString = "legacyUserProfileCustomizations" | |
$filePath = "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))\user.js" | |
if (Test-Path "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))\user.js") { | |
if (Select-String -Path $filePath -Pattern $knownString -Quiet) { | |
Write-Host "String '$knownString' found in the file." | |
} else { | |
Add-Content "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))\user.js" "user_pref(""toolkit.legacyUserProfileCustomizations.stylesheets"", true);" | |
} | |
} else { | |
Add-Content "$env:APPDATA\Mozilla\Firefox\$($FFProfile.replace("/","\"))\user.js" "user_pref(""toolkit.legacyUserProfileCustomizations.stylesheets"", true);" | |
} | |
} | |
PROCESS { | |
$version = Invoke-WebRequest -UseBasicParsing "https://api.github.com/repos/datguypiko/Firefox-Mod-Blur/releases/latest" | ConvertFrom-Json | |
Get-File -PATH ([IO.Path]::GetTempPath()) -filename "Firefox-Mod-Blur.zip" -URL $($version.assets.browser_download_url | Where-Object {$_ -like "*.zip"}) | |
New-Item -Path ([IO.Path]::GetTempPath()) -Name "Firefox-Mod-Blur" -ItemType "directory" -Force | |
Expand-Archive -LiteralPath "$([IO.Path]::GetTempPath())Firefox-Mod-Blur.zip" -DestinationPath "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\" | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Homepage mods\Circular homepage shortcuts\circular_homepage_shortcuts.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Compact extensions menu\Style 1\cleaner_extensions_menu.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Icon and Button Mods\Icons in main menu\icons_in_main_menu.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Min-max-close control buttons\Right side default system buttons\MenuButtonsOnLeft\min-max-close_buttons.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Tabs Bar Mods\Colored sound playing tab\colored_soundplaying_tab.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Search Bar Mods\Search box - No search engine buttons\no_search_engines_in_url_bar.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Tabs Bar Mods\Pinned Tabs - no background color\pinned_tabs_no_bg_color.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Search Bar Mods\Search box - no border\url_bar_no_border.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\EXTRA MODS\Tabs Bar Mods\Tabs - reversed background color\reversed_tabs_bg_color.css" -Destination $FFChromePath -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\userChrome.css" -Destination "$FFChromePath\old_userChrome.css" | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\userContent.css" -Destination "$FFChromePath\old_userContent.css" | |
New-Item -Path $FFChromePath -Name "ASSETS" -ItemType "directory" -Force | |
Copy-Item "$([IO.Path]::GetTempPath())Firefox-Mod-Blur\ASSETS\*" "$FFChromePath\ASSETS" -Recurse -Force | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())Firefox-Mod-Blur" | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())Firefox-Mod-Blur.zip" | |
################################################################################# | |
get-file -PATH $([IO.Path]::GetTempPath()) -filename "nox.zip" -URL "https://github.com/Izheil/Quantum-Nox-Firefox-Dark-Full-Theme/archive/refs/heads/master.zip" | |
New-Item -Path $([IO.Path]::GetTempPath()) -Name "nox" -ItemType "directory" -Force | |
Expand-Archive -LiteralPath "$([IO.Path]::GetTempPath())nox.zip" -DestinationPath "$([IO.Path]::GetTempPath())nox\" | |
Copy-Item "$([IO.Path]::GetTempPath())nox\Quantum-Nox-Firefox-Dark-Full-Theme-master\Multirow and other functions\JS Loader\root\defaults\pref\config-prefs.js" -Destination "$($ffEXE.DirectoryName)\defaults\pref\config-prefs.js" -Recurse -Force | |
Copy-Item "$([IO.Path]::GetTempPath())nox\Quantum-Nox-Firefox-Dark-Full-Theme-master\Multirow and other functions\JS Loader\root\config.js" -Destination $ffEXE.DirectoryName -Recurse -Force | |
New-Item -Path $FFChromePath -Name "utils" -ItemType "directory" -Force | |
Copy-Item "$([IO.Path]::GetTempPath())nox\Quantum-Nox-Firefox-Dark-Full-Theme-master\Multirow and other functions\JS Loader\utils\*" -Destination "$FFChromePath\utils" -Recurse -Force | |
Copy-Item "$([IO.Path]::GetTempPath())nox\Quantum-Nox-Firefox-Dark-Full-Theme-master\Multirow and other functions\Multirow tabs\MultiRowTabLiteforFx.uc.js" -Destination "$FFChromePath" | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())nox" | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())nox.zip" | |
################################################################################# | |
get-file -PATH $([IO.Path]::GetTempPath()) -filename "override.zip" -URL "https://github.com/go2tom42/Firefox-Mod-Blur-override/archive/refs/heads/master.zip" | |
New-Item -Path $([IO.Path]::GetTempPath()) -Name "override" -ItemType "directory" -Force | |
Expand-Archive -LiteralPath "$([IO.Path]::GetTempPath())override.zip" -DestinationPath "$([IO.Path]::GetTempPath())override\" | |
Copy-Item "$([IO.Path]::GetTempPath())override\Firefox-Mod-Blur-override-master\override\*.css" -Destination "$FFChromePath" -Force | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())override" | |
Remove-Item -Recurse -Force "$([IO.Path]::GetTempPath())override.zip" | |
} | |
END { | |
&$ffEXE | |
} | |
} | |
Update-FFTheme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment