Files
ffproxy/ffproxy.sh

98 lines
2.8 KiB
Bash
Raw Normal View History

2025-08-18 15:45:46 +02:00
#!/bin/bash
function istruzioni() {
echo "[Utility per tunnel SOCKS5 su Chromium]"
echo
echo "utilizzo: ffproxy <SOCKS5 PORT[1025-65535]> [-i] [-p]"
echo
echo "esempio:"
echo "Su una finestra del terminale: ssh user@server.mio -D 1234"
echo "Su un'altra finestra del terminale: ffproxy 1234"
echo "Argomenti"
echo "-i attiva incognito mode"
echo "-p uBlock Origin preinstallato"
}
2025-08-18 15:50:08 +02:00
# Funzione scarica e installa ublock origin
2025-08-18 15:45:46 +02:00
function ublock() {
2025-08-18 15:50:08 +02:00
# Se la cartella del profilo sock5$PORT nonn esiste
2025-08-18 15:45:46 +02:00
if [ ! -d "/home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions" ]; then
2025-08-18 15:50:08 +02:00
# Trova la vers 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/..$//')
2025-08-18 15:45:46 +02:00
mkdir -p /home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions
cd /home/$USER/.mozilla/firefox/ffproxy/socks5-$PORT/extensions
2025-08-18 15:50:08 +02:00
# Scarica ublock Origin
2025-08-18 15:45:46 +02:00
wget -q https://github.com/gorhill/uBlock/releases/download/$VERS.1b7/uBlock0_$VERS.1b7.firefox.signed.xpi
2025-08-18 15:50:08 +02:00
# Compila il manifest.json
2025-08-18 15:45:46 +02:00
cat <<EOL > ~/.mozilla/firefox/ffproxy/socks5-$PORT/extensions/manifest.json
{
"manifest_version": 2,
"name": "uBlock Origin",
"version": "$VERS.1b7",
"applications": {
"gecko": {
"id": "uBlock0@raymondhill.net"
}
}
}
EOL
fi
}
2025-08-18 15:50:08 +02:00
# Mostra Help
2025-08-18 15:45:46 +02:00
if [ "$1" = "-h" -o "$1" = "--help" ]
then
istruzioni
exit 3
fi
# Variabili
PORT=$1
PROFILE_DIR="$HOME/.mozilla/firefox/ffproxy/socks5-$PORT"
VERS=""
incognito_option=""
plugin_option=""
2025-08-18 15:50:08 +02:00
# Crea un nuovo profilo Firefox se non esiste
if [ ! -d "PROFILE_DIR" ]; then
2025-08-18 15:45:46 +02:00
mkdir -p "$PROFILE_DIR"
firefox -no-remote -CreateProfile "socks5-$PORT" "$PROFILE_DIR"
# Modifica prefs.js con configurazione proxy
PREFS_FILE="$PROFILE_DIR/prefs.js"
echo 'user_pref("network.proxy.type", 1);' >> "$PREFS_FILE"
echo 'user_pref("network.proxy.socks", "127.0.0.1");' >> "$PREFS_FILE"
echo "user_pref(\"network.proxy.socks_port\", $PORT);" >> "$PREFS_FILE"
echo 'user_pref("network.proxy.socks_remote_dns", true);' >> "$PREFS_FILE"
2025-08-18 15:50:08 +02:00
fi
2025-08-18 15:45:46 +02:00
# Check argomenti
for arg in "$@"; do
case $arg in
-i)
incognito_option="--private-window"
;;
-p)
ublock
;;
-ip)
incognito_option="--private-window"
ublock
;;
-pi)
ublock
incognito_option="--private-window"
;;
esac
done
# Mostra comando da avviare
echo -e '\nfirefox '$incognito_option $plugin_option' -no-remote -P "socks5-'$PORT'"\n'
# Avvia Firefox con quel profilo
firefox $incognito_option -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &