non ancora ublock

This commit is contained in:
scossa
2025-08-18 19:30:45 +02:00
parent 5d28931a10
commit 3a4c6fd863

View File

@@ -15,6 +15,13 @@ function istruzioni() {
}
function sed_extensions-preferences() {
# Aspetta 3 secondi (per far creare il file extension-preferences.json) e poi lo modifica
sleep 3
ls $PROFILE_DIR/extension-preferences.json
sed -i '$ s/}/,"uBlock0@raymondhill.net":{"permissions":["internal:privateBrowsingAllowed"],"origins":[]}}/' $PROFILE_DIR/extension-preferences.json
}
# Funzione scarica e installa ublock origin
function ublock() {
@@ -23,24 +30,47 @@ function ublock() {
# 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 )
LINK_VERS=$(curl -s https://api.github.com/repos/gorhill/uBlock/releases/latest | jq -r '.assets[] | select(.name | test("firefox")) | .browser_download_url')
mkdir -p $PROFILE_DIR/extensions
cd $PROFILE_DIR/extensions
mkdir -p /$PROFILE_DIR/extensions
cd /$PROFILE_DIR/extensions
# Scarica ublock Origin
wget -q $LINK_VERS
echo -e "\n$LINK_VERS\n"
echo -e "\n Scarico il file: $LINK_VERS\n"
# Compila il manifest.json
cat <<EOL > $PROFILE_DIR/extensions/manifest.json
# # Compila il manifest.json
cat <<EOL > /$PROFILE_DIR/extension-settings.json
{
"manifest_version": 2,
"name": "uBlock Origin",
"version": "$VERS.1b7",
"applications": {
"gecko": {
"id": "uBlock0@raymondhill.net"
"version": 3,
"url_overrides": {},
"prefs": {
"websites.hyperlinkAuditingEnabled": {
"initialValue": {},
"precedenceList": [
{
"id": "uBlock0@raymondhill.net",
"installDate": 1755534027851,
"value": false,
"enabled": true
}
]
},
"network.networkPredictionEnabled": {
"initialValue": {},
"precedenceList": [
{
"id": "uBlock0@raymondhill.net",
"installDate": 1755534027851,
"value": false,
"enabled": true
}
]
}
},
"tabHideNotification": {},
"homepageNotification": {},
"default_search": {},
"newTabNotification": {},
"commands": {}
}
EOL
@@ -48,8 +78,6 @@ EOL
# da il nome giusto al file xpi
name=$(ls $PROFILE_DIR/extensions/uBlock*)
echo $name
echo 'mv $name $PROFILE_DIR/extensions/uBlock0@raymondhill.net.xpi'
mv "$name" "$PROFILE_DIR/extensions/uBlock0@raymondhill.net.xpi"
}
@@ -68,6 +96,7 @@ LINK_VERS=""
VERS=""
incognito_option=""
plugin_option=""
dio="ciao"
# Crea un nuovo profilo Firefox se non esiste
if [ ! -d "$PROFILE_DIR" ]; then
@@ -77,7 +106,7 @@ if [ ! -d "$PROFILE_DIR" ]; then
# Modifica prefs.js con configurazione proxy
PREFS_FILE="$PROFILE_DIR/prefs.js"
echo 'user_pref("network.proxy.type", 1);' >> "$PREFS_FILE"
echo 'u/ser_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"
@@ -85,14 +114,11 @@ fi
# mette nella var il path sbagliato
schifo=$(awk '/socks5-'$PORT'/ && /Path/ {print; exit}' $HOME/.mozilla/firefox/profiles.ini) ; echo "$schifo"
schifo=$(awk '/socks5-'$PORT'/ && /Path/ {print; exit}' $HOME/.mozilla/firefox/profiles.ini)
# cancella la cartella con nome sbagliato
dio=$(echo $schifo | sed 's/Path=//g')
#echo $dio
#echo "$HOME/.mozilla/firefox/$dio"
rm -rf "$HOME/.mozilla/firefox/$dio"
# sotituisce il testo sbagliato con quello giusto
# sotituisce il testo sbagliato con quello giusto nel file profiles.ini
sed -i '/socks5-'$PORT'/ { /Path/ s/'$schifo'/Path=socks5-'$PORT'/; }' $HOME/.mozilla/firefox/profiles.ini
@@ -122,3 +148,11 @@ echo -e '\nfirefox'$incognito_option'-no-remote -P "socks5-'$PORT'"\n'
# Avvia Firefox con quel profilo
firefox $incognito_option -no-remote -P "socks5-$PORT" > /dev/null 2>&1 &
# Aspetta 3 secondi (per far creare il file extension-preferences.json) e poi lo modifica
sed_extensions-preferences
#DEV RESET
#alias RESET="cd /home/$USER/.mozilla/firefox; rm -rf /home/$USER/.mozilla/firefox/*socks5-$PORT; firefox --ProfileManager"