From a1e88f844f30cbd9199d3c947832204023901a17 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 9 Feb 2023 21:09:53 +0000 Subject: [PATCH 01/14] create install script --- install.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..27d4b7d --- /dev/null +++ b/install.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +echo "Detecting if firefox is installed on your system..." +if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then + echo "ERROR: firefox not found..." + + ans="y" + read -e -i "$ans" -p "Do you want to continue anyway? (y/n): " in + ans="${in:-$ans}"; + + if [[ ! ${ans,,} =~ ^(yes|y)$ ]]; then + exit 0; + fi +fi + +git --version 2>&1 > /dev/null; +if [ ! $? -eq 0 ]; then + echo "git is not installed... Please install it." + exit 0; +fi + +# Finding profile root directory +PROFILE_ROOTDIR=$(find ~/.mozilla/firefox -type d -iname "*.default-release"); + +# Prompting for correct install directory +read -e -i "$PROFILE_ROOTDIR" -p "Enter profile root directory: " newdir +PROFILE_ROOTDIR="${newdir:-$PROFILE_ROOTDIR}" + +if [ ! -d "$PROFILE_ROOTDIR" ]; then + echo "ERROR: firefox profile directory could not be found" + + while [ ! -d "$PROFILE_ROOTDIR" ]; do + read -p "Enter active root directory found in about:profiles here: " PROFILE_ROOTDIR; + + if [ ! -d "$PROFILE_ROOTDIR" ]; then + echo "invalid directory: specified location does not exist. Try again..." + fi + done; +fi + +echo "cloning repository"; +if [ ! -d ~/github/firefox-dracula ]; then + if ! git clone https://github.com/jannikbuscha/firefox-dracula.git ~/github/firefox-dracula; then + echo "Error while cloning repository into ~/github/firefox-dracula..." + exit 0; + fi +fi + +echo "Copying theme folder..." +cp -r ~/github/firefox-dracula/chrome "$PROFILE_ROOTDIR" + +# firefox will automatically sort out any duplicate issues, whatever is at the end of the file takes priority, so this works. +echo "Adding necessary configs..." +echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);" >> $PROFILE_ROOTDIR/prefs.js; +echo "user_pref(\"svg.context-properties.content.enabled\", true);" >> $PROFILE_ROOTDIR/prefs.js; +echo "user_pref(\"layout.css.color-mix.enabled\", true);" >> $PROFILE_ROOTDIR/prefs.js; +if [[ $OSTYPE == "darwin"* ]]; then + echo "user_pref(\"widget.macos.native-context-menus\", false);" >> $PROFILE_ROOTDIR/prefs.js; +fi + +echo "Finished successfully! Please (re)start firefox to see the changes."; From 41ac13de12d526a2f992979066d0dbc8989f4cf9 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 9 Feb 2023 21:43:09 +0000 Subject: [PATCH 02/14] add variables to top for easy configuration --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 27d4b7d..0d1c7f6 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,11 @@ #!/bin/bash +# VARIABLES, CHANGE AS NEEDED +GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" +PROFILE_ROOTDIR=$(find ~/.mozilla/firefox -type d -iname "*.default-release"); + + + echo "Detecting if firefox is installed on your system..." if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then echo "ERROR: firefox not found..." @@ -19,8 +25,6 @@ if [ ! $? -eq 0 ]; then exit 0; fi -# Finding profile root directory -PROFILE_ROOTDIR=$(find ~/.mozilla/firefox -type d -iname "*.default-release"); # Prompting for correct install directory read -e -i "$PROFILE_ROOTDIR" -p "Enter profile root directory: " newdir @@ -40,7 +44,7 @@ fi echo "cloning repository"; if [ ! -d ~/github/firefox-dracula ]; then - if ! git clone https://github.com/jannikbuscha/firefox-dracula.git ~/github/firefox-dracula; then + if ! git clone $GITHUB_REPO ~/github/firefox-dracula; then echo "Error while cloning repository into ~/github/firefox-dracula..." exit 0; fi From 5c028ce258b028d7c89c9084f2529e2095cd0aad Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 9 Feb 2023 22:18:47 +0000 Subject: [PATCH 03/14] detect profile folder automatically --- install.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 0d1c7f6..01710ab 100644 --- a/install.sh +++ b/install.sh @@ -2,9 +2,7 @@ # VARIABLES, CHANGE AS NEEDED GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" -PROFILE_ROOTDIR=$(find ~/.mozilla/firefox -type d -iname "*.default-release"); - - +PROFILE_ROOTDIR=~/.mozilla/firefox/$(grep Default= ~/.mozilla/firefox/installs.ini | tail -1 | cut -c 9-); echo "Detecting if firefox is installed on your system..." if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then @@ -25,7 +23,6 @@ if [ ! $? -eq 0 ]; then exit 0; fi - # Prompting for correct install directory read -e -i "$PROFILE_ROOTDIR" -p "Enter profile root directory: " newdir PROFILE_ROOTDIR="${newdir:-$PROFILE_ROOTDIR}" @@ -34,7 +31,7 @@ if [ ! -d "$PROFILE_ROOTDIR" ]; then echo "ERROR: firefox profile directory could not be found" while [ ! -d "$PROFILE_ROOTDIR" ]; do - read -p "Enter active root directory found in about:profiles here: " PROFILE_ROOTDIR; + read -p "Enter active root directory found in \"about:profiles\" here: " PROFILE_ROOTDIR; if [ ! -d "$PROFILE_ROOTDIR" ]; then echo "invalid directory: specified location does not exist. Try again..." From 58b032a527d9c1c7ea7ecb6c06cd3639f94a8110 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 9 Feb 2023 23:10:20 +0000 Subject: [PATCH 04/14] add uninstall option --- install.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/install.sh b/install.sh index 01710ab..f2ac0a6 100644 --- a/install.sh +++ b/install.sh @@ -4,6 +4,17 @@ GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" PROFILE_ROOTDIR=~/.mozilla/firefox/$(grep Default= ~/.mozilla/firefox/installs.ini | tail -1 | cut -c 9-); +# Check if issued `./installer.sh uninstall` +if [[ $1 == "uninstall" ]]; then + rm -rfi $PROFILE_ROOTDIR/chrome; + echo "uninstalling..."; + echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", false);" >> $PROFILE_ROOTDIR/prefs.js; + echo "user_pref(\"svg.context-properties.content.enabled\", false);" >> $PROFILE_ROOTDIR/prefs.js; + echo "user_pref(\"layout.css.color-mix.enabled\", false);" >> $PROFILE_ROOTDIR/prefs.js; + + exit 0; +fi + echo "Detecting if firefox is installed on your system..." if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then echo "ERROR: firefox not found..." From 9888aed7de96a532182a280c0f43de2d89ab3369 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 9 Feb 2023 23:10:46 +0000 Subject: [PATCH 05/14] edit README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8373700..d90280d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ A Firefox userChrome.css theme that aims to recreate the look and feel of the Ch thumbnail screenshot ## How to install +### Via install script +```bash +curl https://raw.githubusercontent.com/bmFtZQ/edge-frfox/blob/main/install.sh > /tmp/installer.sh && chmod +x /tmp/installer.sh && /tmp/installer.sh +``` + +### Manual Installation 1. Go to `about:support` and click the "Open Folder/Show in Finder" button for the root directory of your browser profile/s. 2. Download and copy the `chrome` folder into the profile folder. 3. Go to about:config and change these preferences: From 0c341deea094cc4f30efa4fd7774131828c86591 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Fri, 10 Feb 2023 23:06:41 +0000 Subject: [PATCH 06/14] clean up and optimize pref-setting method --- install.sh | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index f2ac0a6..e0b0736 100644 --- a/install.sh +++ b/install.sh @@ -3,15 +3,33 @@ # VARIABLES, CHANGE AS NEEDED GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" PROFILE_ROOTDIR=~/.mozilla/firefox/$(grep Default= ~/.mozilla/firefox/installs.ini | tail -1 | cut -c 9-); +CHANGED_PREFS=("toolkit.legacyUserProfileCustomizations.stylesheets" "svg.context-properties.content.enabled" "layout.css.color-mix.enabled") + +# UTILITY FUNCTIONS +set_pref() { + echo "setting $1 to $2 in prefs.js"; + echo "user_pref(\"$1\", $2);" >> $PROFILE_ROOTDIR/prefs.js; +} + +delete_pref() { + echo "resetting $1 to default" + sed -i "/user_pref(\"$1\", \(true\|false\));/d" $PROFILE_ROOTDIR/prefs.js; +} + +##################### +# PRE-INSTALL PHASE # +##################### # Check if issued `./installer.sh uninstall` if [[ $1 == "uninstall" ]]; then + echo "Warning: the following command will delete said folder and wipe out everything in its sub-directories" rm -rfi $PROFILE_ROOTDIR/chrome; echo "uninstalling..."; - echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", false);" >> $PROFILE_ROOTDIR/prefs.js; - echo "user_pref(\"svg.context-properties.content.enabled\", false);" >> $PROFILE_ROOTDIR/prefs.js; - echo "user_pref(\"layout.css.color-mix.enabled\", false);" >> $PROFILE_ROOTDIR/prefs.js; + for pref in ${CHANGED_PREFS[@]}; do + delete_pref $pref; + done; + echo "uninstall complete." exit 0; fi @@ -30,7 +48,7 @@ fi git --version 2>&1 > /dev/null; if [ ! $? -eq 0 ]; then - echo "git is not installed... Please install it." + echo "ERROR: git is not installed... Please install it." exit 0; fi @@ -50,24 +68,30 @@ if [ ! -d "$PROFILE_ROOTDIR" ]; then done; fi -echo "cloning repository"; -if [ ! -d ~/github/firefox-dracula ]; then - if ! git clone $GITHUB_REPO ~/github/firefox-dracula; then - echo "Error while cloning repository into ~/github/firefox-dracula..." +################# +# INSTALL PHASE # +################# + +echo "Installing..." +if [ ! -d ~/github/edge-frfox ]; then + echo "cloning repository"; + if ! git clone $GITHUB_REPO ~/github/edge-frfox; then + echo "Error while cloning repository into ~/github/edge-frfox..." exit 0; fi fi echo "Copying theme folder..." -cp -r ~/github/firefox-dracula/chrome "$PROFILE_ROOTDIR" +cp -r ~/github/edge-frfox/chrome "$PROFILE_ROOTDIR" # firefox will automatically sort out any duplicate issues, whatever is at the end of the file takes priority, so this works. echo "Adding necessary configs..." -echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);" >> $PROFILE_ROOTDIR/prefs.js; -echo "user_pref(\"svg.context-properties.content.enabled\", true);" >> $PROFILE_ROOTDIR/prefs.js; -echo "user_pref(\"layout.css.color-mix.enabled\", true);" >> $PROFILE_ROOTDIR/prefs.js; +for pref in ${CHANGED_PREFS[@]}; do + set_pref $pref "true" +done; + if [[ $OSTYPE == "darwin"* ]]; then - echo "user_pref(\"widget.macos.native-context-menus\", false);" >> $PROFILE_ROOTDIR/prefs.js; + set_pref "widget.macos.native-context-menus" "false" fi echo "Finished successfully! Please (re)start firefox to see the changes."; From bcf1ea15fd7cecddeda0e3cadde5c5626b9d8da0 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Sat, 11 Feb 2023 00:00:37 +0000 Subject: [PATCH 07/14] README.md fix linux/macos install section --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d90280d..e044ac0 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,17 @@ A Firefox userChrome.css theme that aims to recreate the look and feel of the Ch thumbnail screenshot ## How to install -### Via install script -```bash -curl https://raw.githubusercontent.com/bmFtZQ/edge-frfox/blob/main/install.sh > /tmp/installer.sh && chmod +x /tmp/installer.sh && /tmp/installer.sh +### Via Linux and MacOS shell script +Paste this into your terminal emulator: +```sh +# Linux may not have $TMPDIR set by default +if [ -z $TMPDIR ]; then TMPDIR=/tmp; fi; + +curl https://raw.githubusercontent.com/bmFtZQ/edge-frfox/blob/main/install.sh > $TMPDIR/installer.sh && chmod +x $TMPDIR/installer.sh && sh $TMPDIR/installer.sh ``` +Uninstallation can be done by just writing `uninstall` at the end of the script above + ### Manual Installation 1. Go to `about:support` and click the "Open Folder/Show in Finder" button for the root directory of your browser profile/s. 2. Download and copy the `chrome` folder into the profile folder. From a9cd9145d9d006a608bf85c7756f3ee4a21a99fd Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Sat, 11 Feb 2023 00:42:12 +0000 Subject: [PATCH 08/14] detect if firefox is running --- install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e0b0736..69c7474 100644 --- a/install.sh +++ b/install.sh @@ -33,6 +33,13 @@ if [[ $1 == "uninstall" ]]; then exit 0; fi +firefox_proc=$(pgrep firefox); +if [ ! -z $firefox_proc ]; then + echo "Before installing, please make sure firefox is not running." + echo "Otherwise, changes cannot be made to prefs.js" + exit 0; +fi + echo "Detecting if firefox is installed on your system..." if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then echo "ERROR: firefox not found..." @@ -94,4 +101,4 @@ if [[ $OSTYPE == "darwin"* ]]; then set_pref "widget.macos.native-context-menus" "false" fi -echo "Finished successfully! Please (re)start firefox to see the changes."; +echo "Finished successfully! Please start firefox to see the changes."; From 7e0ba72e78deac57dbb00a3d0e8561db49210c04 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Wed, 15 Feb 2023 18:19:33 +0000 Subject: [PATCH 09/14] check dev edition --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 69c7474..bbe2655 --- a/install.sh +++ b/install.sh @@ -41,7 +41,7 @@ if [ ! -z $firefox_proc ]; then fi echo "Detecting if firefox is installed on your system..." -if [ ! -f /usr/bin/firefox ] || { [ ! -f /usr/lib/firefox/firefox ]; }; then +if [ ! -f /usr/bin/firefox ] && { [ ! -f /usr/lib/firefox/firefox ] && [ ! -f /usr/lib/firefox-developer-edition/firefox ]; }; then echo "ERROR: firefox not found..." ans="y" From 366f9a9f0a2fa37bea063c7c4793812181f95853 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Wed, 15 Feb 2023 18:29:44 +0000 Subject: [PATCH 10/14] check if firefox running before uninstall --- install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index bbe2655..8e46bb6 100755 --- a/install.sh +++ b/install.sh @@ -20,6 +20,13 @@ delete_pref() { # PRE-INSTALL PHASE # ##################### +firefox_proc=$(pgrep firefox); +if [ ! -z $firefox_proc ]; then + echo "Before installing, please make sure firefox is not running." + echo "Otherwise, changes cannot be made to prefs.js" + exit 0; +fi + # Check if issued `./installer.sh uninstall` if [[ $1 == "uninstall" ]]; then echo "Warning: the following command will delete said folder and wipe out everything in its sub-directories" @@ -33,13 +40,6 @@ if [[ $1 == "uninstall" ]]; then exit 0; fi -firefox_proc=$(pgrep firefox); -if [ ! -z $firefox_proc ]; then - echo "Before installing, please make sure firefox is not running." - echo "Otherwise, changes cannot be made to prefs.js" - exit 0; -fi - echo "Detecting if firefox is installed on your system..." if [ ! -f /usr/bin/firefox ] && { [ ! -f /usr/lib/firefox/firefox ] && [ ! -f /usr/lib/firefox-developer-edition/firefox ]; }; then echo "ERROR: firefox not found..." From 87790768b3524498afe316c412251599398b5c28 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 16 Feb 2023 20:48:07 +0000 Subject: [PATCH 11/14] add windows install.ps1 --- install.ps1 | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++ install.sh | 64 ++++++++++++++-------------- 2 files changed, 150 insertions(+), 32 deletions(-) create mode 100644 install.ps1 diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..f3108ca --- /dev/null +++ b/install.ps1 @@ -0,0 +1,118 @@ +# Get-ExecutionPolcy = "Restricted" by default + +# VARIABLES, CHANGE AS NEEDED +$GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" +$PROJECT_NAME=$($GITHUB_REPO.Split("/")[-1] -replace ".git", "") +$FIREFOX_DIR="$env:APPDATA\Mozilla\Firefox"; +$PROFILE_ROOTDIR="$($FIREFOX_DIR)\Profiles\$((Select-String -Path "$($FIREFOX_DIR)\installs.ini" -Pattern "Default=" | Select-Object -Last 1).Line.Substring(17))"; +$CHANGED_PREFS=@("toolkit.legacyUserProfileCustomizations.stylesheets", "svg.context-properties.content.enabled", "layout.css.color-mix.enabled"); + +# UTILITY FUNCTIONS +function set_pref { + param ( + $Pref, + $Bool + ) + + Write-Output "setting $pref to $bool in prefs.js"; + "user_pref(`"$pref`", $bool);" | out-file "$PROFILE_ROOTDIR/prefs.js" -Encoding ASCII -append +} + +function delete_pref { + param ( + $Pref + ) + + $Prefsjs="$PROFILE_ROOTDIR\prefs.js"; + + Write-Output "resetting $Pref to default"; + (Get-Content -Path $Prefsjs) | + ForEach-Object {$_ -Replace "user_pref\(\`"$Pref\`", (true|false)\);", ''} | + Set-Content -Path $Prefsjs; +} + +##################### +# PRE-INSTALL PHASE # +##################### + +$firefox_proc=Get-Process firefox -ErrorAction SilentlyContinue; +if ($firefox_proc) { + Write-Output "ERROR: Before installing, please make sure firefox is not running.`nOtherwise, changes cannot be made to prefs.js"; + exit 0; +} + +# Prompting for correct install directory +Write-Output " +Please enter the path to your firefox profile directory. +This can be found by opening about:support in firefox and looking for the Profile root directory. +Press CTRL+C to abort installation now. +Automatically detected: $PROFILE_ROOTDIR +Press ENTER to use this directory, or type in a new one."; +$ans=Read-Host "Path"; +$PROFILE_ROOTDIR=($PROFILE_ROOTDIR,$ans)[[bool]$ans]; + +# Check if issued `...\installer.sh uninstall` +if ($args[0] -eq "uninstall") { + Remove-Item "$PROFILE_ROOTDIR/chrome" -Recurse -Confirm:$true; + + Write-Output "uninstalling..."; + foreach ($pref in $CHANGED_PREFS) { + delete_pref $pref; + } + + Write-Output "uninstall complete."; + exit 0; +} + +Write-Output "Checking if git is installed..."; +if (!(Get-Command git -ErrorAction SilentlyContinue)) { + Write-Output "ERROR: git not found... Please install git and try again."; + exit 0; +} + +Write-Output "Detecting if firefox is installed on your system..." +if (!(Test-Path $FIREFOX_DIR)) { + Write-Output "ERROR: firefox not found..."; + + Write-Output "Do you want to continue anyway?"; + $continue=Read-Host -Prompt "y/n"; + + if (!("$continue".ToLower() -match "^(y|yes)$")) { + Write-Output "Aborting installation..."; + exit 0; + } +} + +if (!(Test-Path "$PROFILE_ROOTDIR")) { + Write-Host "ERROR: firefox profile directory could not be found..." -ForegroundColor Red; + + do { + $PROFILE_ROOTDIR=Read-Host -Prompt "Enter active root directory found in about:support here"; + if (!(Test-Path "$PROFILE_ROOTDIR")) { + Write-Host "invalid directory: specified location does not exist. Try again..." -ForegroundColor Red; + } + } while (!(Test-Path "$PROFILE_ROOTDIR")); +} + +################# +# INSTALL PHASE # +################# + +Write-Host "Installing..." -ForegroundColor Green; +if (!(Test-Path "$("$env:temp\$PROJECT_NAME")")) { + Write-Output "Cloning $GITHUB_REPO into $env:temp\$PROJECT_NAME..."; + + git clone $GITHUB_REPO "$env:temp\$PROJECT_NAME"; +} + +Write-Output "Copying files to $PROFILE_ROOTDIR\chrome..."; +Remove-Item "$PROFILE_ROOTDIR\chrome" -Recurse -ErrorAction SilentlyContinue -Confirm:$false -Force; +Copy-Item "$env:temp\$PROJECT_NAME\chrome" -Destination $PROFILE_ROOTDIR -Recurse -Force; + +# firefox will automatically sort out any duplicate issues, whatever is at the end of the file takes priority, so this works. +Write-Output "Setting preferences..."; +foreach ($pref in $CHANGED_PREFS) { + set_pref $pref "true"; +} + +Write-Host "Installation complete! Please start firefox to see the changes.`n`n" -ForegroundColor Green; diff --git a/install.sh b/install.sh index 8e46bb6..2f84f4f 100755 --- a/install.sh +++ b/install.sh @@ -27,38 +27,6 @@ if [ ! -z $firefox_proc ]; then exit 0; fi -# Check if issued `./installer.sh uninstall` -if [[ $1 == "uninstall" ]]; then - echo "Warning: the following command will delete said folder and wipe out everything in its sub-directories" - rm -rfi $PROFILE_ROOTDIR/chrome; - echo "uninstalling..."; - for pref in ${CHANGED_PREFS[@]}; do - delete_pref $pref; - done; - - echo "uninstall complete." - exit 0; -fi - -echo "Detecting if firefox is installed on your system..." -if [ ! -f /usr/bin/firefox ] && { [ ! -f /usr/lib/firefox/firefox ] && [ ! -f /usr/lib/firefox-developer-edition/firefox ]; }; then - echo "ERROR: firefox not found..." - - ans="y" - read -e -i "$ans" -p "Do you want to continue anyway? (y/n): " in - ans="${in:-$ans}"; - - if [[ ! ${ans,,} =~ ^(yes|y)$ ]]; then - exit 0; - fi -fi - -git --version 2>&1 > /dev/null; -if [ ! $? -eq 0 ]; then - echo "ERROR: git is not installed... Please install it." - exit 0; -fi - # Prompting for correct install directory read -e -i "$PROFILE_ROOTDIR" -p "Enter profile root directory: " newdir PROFILE_ROOTDIR="${newdir:-$PROFILE_ROOTDIR}" @@ -75,6 +43,38 @@ if [ ! -d "$PROFILE_ROOTDIR" ]; then done; fi +# Check if issued `./installer.sh uninstall` +if [[ $1 == "uninstall" ]]; then + echo "Warning: the following command will delete said folder and wipe out everything in its sub-directories" + rm -rfi $PROFILE_ROOTDIR/chrome; + echo "uninstalling..."; + for pref in ${CHANGED_PREFS[@]}; do + delete_pref $pref; + done; + + echo "uninstall complete." + exit 0; +fi + +git --version 2>&1 > /dev/null; +if [ ! $? -eq 0 ]; then + echo "ERROR: git is not installed... Please install it." + exit 0; +fi + +echo "Detecting if firefox is installed on your system..." +if [ ! -f /usr/bin/firefox ] && { [ ! -f /usr/lib/firefox/firefox ] && [ ! -f /usr/lib/firefox-developer-edition/firefox ]; }; then + echo "ERROR: firefox not found..." + + ans="y" + read -e -i "$ans" -p "Do you want to continue anyway? (y/n): " in + ans="${in:-$ans}"; + + if [[ ! ${ans,,} =~ ^(yes|y)$ ]]; then + exit 0; + fi +fi + ################# # INSTALL PHASE # ################# From 77a786657a830d367c5a593b5519f39f1124830c Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 16 Feb 2023 22:20:04 +0000 Subject: [PATCH 12/14] *nix: MacOS fixes, better active profile assumptions, colors --- install.sh | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 2f84f4f..c83fbe9 100755 --- a/install.sh +++ b/install.sh @@ -2,9 +2,24 @@ # VARIABLES, CHANGE AS NEEDED GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" -PROFILE_ROOTDIR=~/.mozilla/firefox/$(grep Default= ~/.mozilla/firefox/installs.ini | tail -1 | cut -c 9-); +PROJECT_NAME=$(basename $GITHUB_REPO | cut -d '.' -f 1) +TMP_DIR="${TMPDIR:-$(dirname $(mktemp))}" + +if [[ $OSTYPE == "darwin"* ]]; then + FIREFOX_DIR=$HOME/Library/Application\ Support/Firefox/Profiles +else + FIREFOX_DIR=$HOME/.mozilla/firefox +fi; + +PROFILE_ROOTDIR=$FIREFOX_DIR/$(grep -E "Path=.*\.(dev-edition-default|default-.*)" $FIREFOX_DIR/profiles.ini | tail -1 | cut -c 6-); CHANGED_PREFS=("toolkit.legacyUserProfileCustomizations.stylesheets" "svg.context-properties.content.enabled" "layout.css.color-mix.enabled") +# COLORS +GREEN='\033[0;32m' +YELLOW='\033[0;93m' +NC='\033[0m' +CYAN='\033[0;36m' + # UTILITY FUNCTIONS set_pref() { echo "setting $1 to $2 in prefs.js"; @@ -22,13 +37,14 @@ delete_pref() { firefox_proc=$(pgrep firefox); if [ ! -z $firefox_proc ]; then - echo "Before installing, please make sure firefox is not running." + echo "Before (un)installing, please make sure firefox is not running." echo "Otherwise, changes cannot be made to prefs.js" exit 0; fi # Prompting for correct install directory -read -e -i "$PROFILE_ROOTDIR" -p "Enter profile root directory: " newdir +read -e -i "$PROFILE_ROOTDIR" -p $'Enter profile root directory: \e[36m' newdir +echo -e -n "${NC}" PROFILE_ROOTDIR="${newdir:-$PROFILE_ROOTDIR}" if [ ! -d "$PROFILE_ROOTDIR" ]; then @@ -44,9 +60,16 @@ if [ ! -d "$PROFILE_ROOTDIR" ]; then fi # Check if issued `./installer.sh uninstall` -if [[ $1 == "uninstall" ]]; then - echo "Warning: the following command will delete said folder and wipe out everything in its sub-directories" - rm -rfi $PROFILE_ROOTDIR/chrome; +if [[ $1 == "uninstall" ]]; then + echo -e "${YELLOW}NOTE: This is the final opportunity to abort uninstallation by pressing Ctrl+C${NC}"; + ans="n" + read -e -i "$ans" -p "Do you want to delete $PROFILE_ROOTDIR/chrome? (y/n): " in + ans="${in:-$ans}"; + + if [[ ${ans,,} =~ ^(yes|y)$ ]]; then + rm -rf $PROFILE_ROOTDIR/chrome; + fi + echo "uninstalling..."; for pref in ${CHANGED_PREFS[@]}; do delete_pref $pref; @@ -80,16 +103,16 @@ fi ################# echo "Installing..." -if [ ! -d ~/github/edge-frfox ]; then +if [ ! -d $TMP_DIR/$PROJECT_NAME ]; then echo "cloning repository"; - if ! git clone $GITHUB_REPO ~/github/edge-frfox; then - echo "Error while cloning repository into ~/github/edge-frfox..." + if ! git clone $GITHUB_REPO $TMP_DIR/$PROJECT_NAME; then + echo "Error while cloning repository into $TMP_DIR/$PROJECT_NAME..." exit 0; fi fi echo "Copying theme folder..." -cp -r ~/github/edge-frfox/chrome "$PROFILE_ROOTDIR" +cp -r $TMP_DIR/$PROJECT_NAME/chrome "$PROFILE_ROOTDIR" # firefox will automatically sort out any duplicate issues, whatever is at the end of the file takes priority, so this works. echo "Adding necessary configs..." @@ -101,4 +124,4 @@ if [[ $OSTYPE == "darwin"* ]]; then set_pref "widget.macos.native-context-menus" "false" fi -echo "Finished successfully! Please start firefox to see the changes."; +echo -e "${GREEN}Finished successfully! Please start firefox to see the changes."; From ce08109ecb557fcec41a7b7aa8a45d7022b4ee38 Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Thu, 16 Feb 2023 22:41:09 +0000 Subject: [PATCH 13/14] Windows: add same check method for active profile --- install.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install.ps1 b/install.ps1 index f3108ca..85fd55a 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,7 +4,7 @@ $GITHUB_REPO="https://github.com/bmFtZQ/edge-frfox.git" $PROJECT_NAME=$($GITHUB_REPO.Split("/")[-1] -replace ".git", "") $FIREFOX_DIR="$env:APPDATA\Mozilla\Firefox"; -$PROFILE_ROOTDIR="$($FIREFOX_DIR)\Profiles\$((Select-String -Path "$($FIREFOX_DIR)\installs.ini" -Pattern "Default=" | Select-Object -Last 1).Line.Substring(17))"; +$PROFILE_ROOTDIR="$($FIREFOX_DIR)\Profiles\$((Select-String -Path "$($FIREFOX_DIR)\profiles.ini" -Pattern "Path=.*\.(dev-edition-default|default-.*)" | Select-Object -Last 1).Line.Substring(14))"; $CHANGED_PREFS=@("toolkit.legacyUserProfileCustomizations.stylesheets", "svg.context-properties.content.enabled", "layout.css.color-mix.enabled"); # UTILITY FUNCTIONS @@ -37,7 +37,7 @@ function delete_pref { $firefox_proc=Get-Process firefox -ErrorAction SilentlyContinue; if ($firefox_proc) { - Write-Output "ERROR: Before installing, please make sure firefox is not running.`nOtherwise, changes cannot be made to prefs.js"; + Write-Host "ERROR: Before installing, please make sure firefox is not running.`nOtherwise, changes cannot be made to prefs.js" -ForegroundColor Red; exit 0; } @@ -45,9 +45,9 @@ if ($firefox_proc) { Write-Output " Please enter the path to your firefox profile directory. This can be found by opening about:support in firefox and looking for the Profile root directory. -Press CTRL+C to abort installation now. -Automatically detected: $PROFILE_ROOTDIR -Press ENTER to use this directory, or type in a new one."; +Press CTRL+C to abort installation now." +Write-Host "Automatically detected: $PROFILE_ROOTDIR" -ForegroundColor Cyan; +Write-Output "Press ENTER to use this directory, or type in a new one."; $ans=Read-Host "Path"; $PROFILE_ROOTDIR=($PROFILE_ROOTDIR,$ans)[[bool]$ans]; @@ -66,13 +66,13 @@ if ($args[0] -eq "uninstall") { Write-Output "Checking if git is installed..."; if (!(Get-Command git -ErrorAction SilentlyContinue)) { - Write-Output "ERROR: git not found... Please install git and try again."; + Write-Host "ERROR: git not found... Please install git and try again." -ForegroundColor Red; exit 0; } Write-Output "Detecting if firefox is installed on your system..." if (!(Test-Path $FIREFOX_DIR)) { - Write-Output "ERROR: firefox not found..."; + Write-Host "ERROR: firefox not found..." -ForegroundColor Red; Write-Output "Do you want to continue anyway?"; $continue=Read-Host -Prompt "y/n"; @@ -98,7 +98,7 @@ if (!(Test-Path "$PROFILE_ROOTDIR")) { # INSTALL PHASE # ################# -Write-Host "Installing..." -ForegroundColor Green; +Write-Output "Installing..."; if (!(Test-Path "$("$env:temp\$PROJECT_NAME")")) { Write-Output "Cloning $GITHUB_REPO into $env:temp\$PROJECT_NAME..."; @@ -115,4 +115,4 @@ foreach ($pref in $CHANGED_PREFS) { set_pref $pref "true"; } -Write-Host "Installation complete! Please start firefox to see the changes.`n`n" -ForegroundColor Green; +Write-Host "Installation complete! Please start firefox to see the changes.`n" -ForegroundColor Green; From 240b302118450569a7ec3598e3676b3e7b316ebb Mon Sep 17 00:00:00 2001 From: DanielSGH Date: Fri, 17 Feb 2023 00:09:06 +0000 Subject: [PATCH 14/14] Update README.md for Windows users --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e044ac0..ed91ed5 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,23 @@ A Firefox userChrome.css theme that aims to recreate the look and feel of the Ch Paste this into your terminal emulator: ```sh # Linux may not have $TMPDIR set by default -if [ -z $TMPDIR ]; then TMPDIR=/tmp; fi; +TMP_DIR="${TMPDIR:-$(dirname $(mktemp))}" -curl https://raw.githubusercontent.com/bmFtZQ/edge-frfox/blob/main/install.sh > $TMPDIR/installer.sh && chmod +x $TMPDIR/installer.sh && sh $TMPDIR/installer.sh +curl https://raw.githubusercontent.com/bmFtZQ/edge-frfox/create-install-script/install.sh > $TMP_DIR/installer.sh && chmod +x $TMP_DIR/installer.sh && sh $TMP_DIR/installer.sh ``` -Uninstallation can be done by just writing `uninstall` at the end of the script above +### Via Windows Powershell script +**NOTE**: You may need to `Set-ExecutionPolicy RemoteSigned` for this to work, by default, windows will use `Restricted`. +1. Open Powershell as Administrator +2. Type `Set-ExecutionPolicy RemoteSigned` +3. It might ask you to confirm, you should read the contents of [install.ps1](https://raw.githubusercontent.com/bmFtZQ/edge-frfox/create-install-script/install.ps1) and the script below to verify it for yourself. +4. Close out of Powershell and start a new normal instance of Powershell (good practice) +5. Paste the following into powershell and hit enter: +```ps +(curl -Uri https://raw.githubusercontent.com/bmFtZQ/edge-frfox/create-install-script/install.ps1 -UseBasicParsing).Content > $env:temp/installer.ps1; powershell $env:temp\installer.ps1 +``` + +Uninstallation can be done by just writing `uninstall` as a parameter above, so `.../installer.sh uninstall` or `...\installer.ps1 uninstall` for macos/linux and windows respectively ### Manual Installation 1. Go to `about:support` and click the "Open Folder/Show in Finder" button for the root directory of your browser profile/s.