This commit is contained in:
scossa
2025-08-18 16:34:51 +02:00
parent 16050bc233
commit 5bcbd4935f
2 changed files with 50 additions and 27 deletions

View File

@@ -1,46 +1,49 @@
#!/bin/bash #!/bin/bash
set -xeu
function istruzioni() { function istruzioni() {
echo "[Utility per tunnel SOCKS5 su Chromium]" echo -e "\n[Utility per tunnel SOCKS5 su Chromium]"
echo echo
echo "utilizzo: ffproxy <SOCKS5 PORT[1025-65535]> [-i] [-p]" echo "utilizzo: ffproxy <1025-65535> [-i] [-p]"
echo echo
echo "esempio:" echo "esempio:"
echo "Su una finestra del terminale: ssh user@server.mio -D 1234" echo "Su una finestra del terminale: ssh user@server.mio -D 1234"
echo "Su un'altra finestra del terminale: ffproxy 1234" echo "Su un'altra finestra del terminale: ffproxy 1234"
echo "Argomenti" echo "Argomenti"
echo "-i attiva incognito mode" echo "-i attiva incognito mode"
echo "-p uBlock Origin preinstallato" echo -e "-p uBlock Origin preinstallato\n"
} }
# Funzione scarica e installa ublock origin # Funzione scarica e installa ublock origin
function ublock() { function ublock() {
# Se la cartella del profilo sock5$PORT nonn esiste # Se la cartella del profilo socks-$PORT non esiste
if [ ! -d "/home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions" ]; then if [ ! -d "/home/$USER/.mozilla/firefox/socks5-$PORT/extensions" ]; then
# Trova la vers attuale e crea la cartella con il nome della porta # Trova la versione attuale e crea la cartella con il nome della porta
VERS=$(curl -s "https://api.github.com/repos/gorhill/uBlock/releases/latest" | jq -r .tag_name | sed 's/..$//') VERS=$(curl -s "https://api.github.com/repos/gorhill/uBlock/releases/latest" | jq -r .tag_name | sed 's/..$//')
mkdir -p /home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions mkdir -p /home/$USER/.mozilla/firefox/socks5-$PORT/extensions
cd /home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions cd /home/$USER/.mozilla/firefox/socks5-$PORT/extensions
# Scarica ublock Origin # Scarica ublock Origin
wget -q https://github.com/gorhill/uBlock/releases/download/$VERS.1b7/uBlock0_$VERS.1b7.firefox.signed.xpi wget -q https://github.com/gorhill/uBlock/releases/download/$VERS.1b7/uBlock0_$VERS.1b7.firefox.signed.xpi
# Compila il manifest.json # Compila il manifest.json
cat <<EOL > ~/.mozilla/firefox/ffproxy/socks5-$PORT/extensions/manifest.json cat <<EOL > ~/.mozilla/firefox/socks5-1234/extensions/manifest.json
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "uBlock Origin", "name": "uBlock Origin",
"version": "$VERS.1b7", "version": "$VERS.1b7",
"applications": { "applications": {
"gecko": { "gecko": {
"id": "uBlock0@raymondhill.net" "id": "uBlock0@raymondhill.net"
} }
} }
} }
EOL EOL
fi fi
} }
# Mostra Help # Mostra Help
if [ "$1" = "-h" -o "$1" = "--help" ] if [ "$1" = "-h" -o "$1" = "--help" ]
then then
@@ -50,13 +53,13 @@ fi
# Variabili # Variabili
PORT=$1 PORT=$1
PROFILE_DIR="$HOME/.mozilla/firefox/ffproxy/socks5-$PORT" PROFILE_DIR="$HOME/.mozilla/firefox/socks5-$PORT"
VERS="" VERS=""
incognito_option="" incognito_option=""
plugin_option="" plugin_option=""
# Crea un nuovo profilo Firefox se non esiste # Crea un nuovo profilo Firefox se non esiste
if [ ! -d "PROFILE_DIR" ]; then if [ ! -d "$PROFILE_DIR" ]; then
mkdir -p "$PROFILE_DIR" mkdir -p "$PROFILE_DIR"
firefox -no-remote -CreateProfile "socks5-$PORT" "$PROFILE_DIR" firefox -no-remote -CreateProfile "socks5-$PORT" "$PROFILE_DIR"
@@ -73,25 +76,25 @@ fi
for arg in "$@"; do for arg in "$@"; do
case $arg in case $arg in
-i) -i)
incognito_option="--private-window" incognito_option=" --private-window "
;; ;;
-p) -p)
ublock ublock
;; ;;
-ip) -ip)
incognito_option="--private-window" incognito_option=" --private-window "
ublock ublock
;; ;;
-pi) -pi)
ublock ublock
incognito_option="--private-window" incognito_option=" --private-window "
;; ;;
esac esac
done done
# Mostra comando da avviare # Mostra comando da avviare
echo -e '\nfirefox '$incognito_option $plugin_option' -no-remote -P "socks5-'$PORT'"\n' echo -e '\nfirefox'$incognito_option'-no-remote -P "socks5-'$PORT'"\n'
# Avvia Firefox con quel profilo # Avvia Firefox con quel profilo
firefox $incognito_option -no-remote -P "socks5-$PORT" > /dev/null 2>&1 & firefox $incognito_option -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &

View File

@@ -18,7 +18,7 @@ then
fi fi
PORT=$1 PORT=$1
PROFILE_DIR="$HOME/.mozilla/firefox/ffproxy/socks5-$PORT" PROFILE_DIR="$HOME/.mozilla/firefox/socks5-$PORT"
# Crea un nuovo profilo Firefox se non esiste # Crea un nuovo profilo Firefox se non esiste
if [ ! -d "$PROFILE_DIR" ]; then if [ ! -d "$PROFILE_DIR" ]; then
@@ -34,8 +34,28 @@ if [ ! -d "$PROFILE_DIR" ]; then
fi fi
echo -e '\nfirefox -no-remote -P "socks5-'$PORT'"\n' # PORCODIO
VERS=$(curl -s "https://api.github.com/repos/gorhill/uBlock/releases/latest" | jq -r .tag_name | sed 's/..$//')
mkdir -p $PROFILE_DIR/extensions
cd /$PROFILE_DIR/extensions
# Scarica ublock Origin
wget -q https://github.com/gorhill/uBlock/releases/download/$VERS.1b7/uBlock0_$VERS.1b7.firefox.signed.xpi
# Compila il manifest.json
cat <<EOL > $PROFILE_DIR/extensions/manifest.json
{
"manifest_version": 2,
"name": "uBlock Origin",
"version": "$VERS.1b7",
"applications": {
"gecko": {
"id": "uBlock0@raymondhill.net"
}
}
}
EOL
echo -e '\nfirefox -no-remote -P "socks5-'$PORT'"\n'
# Avvia Firefox con quel profilo # Avvia Firefox con quel profilo
firefox -no-remote -P "socks5-$PORT" > /dev/null 2>&1 & firefox -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &