We have moved to a new Sailfish OS Forum. Please start new discussions there.
58

More browser settings to enable/disable javascript, plugins and cookie control

asked 2014-01-23 23:53:40 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2015-07-31 10:38:09 +0200

shfit gravatar image

Apart from private browsing support, I think it is must to have support for configuring javascript, plugin and browser cookies. I am not sure already there is some feature request for this, at least I could not find one.

update: still not implemented in v1.1.2.16

update by shfit: option to block images and other content aswell. maybe like uMatrix plugin for chrome.

edit retag flag offensive close delete

2 Answers

Sort by » oldest newest most voted
1

answered 2014-02-12 11:55:28 +0200

Blizzz gravatar image

Would consider this to be part of https://together.jolla.com/question/4660/enhance-basic-privacy/

edit flag offensive delete publish link more

Comments

@Blizzz thx, just added it there. if you find more, the question is now a wiki, feel free to add, change and update it.

prometoys ( 2014-02-12 22:51:05 +0200 )edit
1

I think this post also addresses a sepparate issue not mentioned in the other post: blocking all these things can save tons of data, which would be helpful if you have a limited data plan. I would also add blocking images to the wishlist. Something like the uMatrix plugin for chrome/Firefox would be awesome..

shfit ( 2015-07-31 10:35:06 +0200 )edit
1

answered 2015-08-04 21:56:43 +0200

Mced gravatar image

As a rough workaround, I've made a bash script called "bro" which handles the following:

―Image loading ON/OFF.

―Javascript ON/OFF.

―Plugins ON/OFF.

It works by modifying the standard Mozilla's 'prefs.js' configuration file (Sailfish stock browser is based on Mozilla). That way, you don't need to enter about:config, accept warning, search, modify and save.

Drawbacks: contrary to "about:config" way, it doesn't allow to make changes on the fly. You must first close browser, then open a terminal, execute the script, finally re-run browser. You must evaluate what is more comfortable and fast. Anyway, if it's just a matter of turning images off, I would recommend Webcat browser.

I ain't a programmer and my code looks horrific. Anyway, to play safe, the script creates a backup before modifying browser's config file. More info, see script's help.

INSTALLING:

―Open a terminal or log into your Sailfish device through SSH.

―Create a 'bin' directory in your home:

mkdir ~/bin

―Download the ZIP file (link below), extract a file called "bro" and move it into that 'bin' directory.

―Make it executable:

chmod +x ~/bin/bro

―Type 'bro', 'bro -h', 'bro -pleaseIneedtoknowhowtocontrolthisone' or 'bro -whatever' for detailed help/instructions. Examples for the smart ones:

$ bro i
# Disable image loading

$ bro Ijp
# Enable image loading, disable javascript, disable plugins

Download link: bro.zip

And that's the script:

#!/bin/bash
# This script changes Sailfish stock browser's config (Mozilla standard
# 'prefs.js' file, located in ~/.mozilla/mozembed/), so user can
# disable or enable images, javascript and plugins.

PREFS_FILE=${HOME}/.mozilla/mozembed/prefs.js

PREFS_IMG='user_pref("permissions.default.image", 2);'
PREFS_JS='user_pref("javascript.enabled", false);'
PREFS_PLUG='user_pref("plugin.disable", false);'

error_info() {
    echo "Usage:"
    echo $(sed 's_.*/\(.*\)_\1_' <<< $0) "[iI][jJ][pP]"
    echo "I: load images"
    echo "i: no images"
    echo "J: turn javascript ON"
    echo "j: turn javascript OFF"
    echo "P: turn plugins ON"
    echo "p: turn plugins OFF"
    echo
    echo "To sum up: uppercase turns ON, lowercase turns OFF."
    echo
    echo "Example: you want to load images, but keep"
    echo "javascript and plugins blocked:"
    echo "bro Ijp"
    echo
    echo "You just want to disable image loading:"
    echo "bro i"
    echo
    echo "If two options are repeated (e.g. 'bro JiPI'),"
    echo "the last one will take effect."
    echo
    echo "First time is executed, it creates a backup in"
    echo "~/.mozilla/mozembed/prefs.js~"
    echo "If something goes wrong, you can restore default settings by"
    echo "typing (close Sailfish browser before):"
    echo "cp ~/.mozilla/mozembed/prefs.js~ ~/.mozilla/mozembed/prefs.js"
    echo
}

add() {
    echo "$1" >> $PREFS_FILE
}

erase() {
    sed -i '/'"$1"'/ s_.*__' $PREFS_FILE
}

# Backup
[[ ! -f ${PREFS_FILE}~ ]] && cp -a $PREFS_FILE ${PREFS_FILE}~

# Starting
if [[ $# -ne 1 ]] || [[ $(grep -i [^ijp] <<< $1) ]]; then
    error_info

elif [[ $(ps aux | grep sailfish-browser | grep -v grep) ]]; then
            echo "Sailfish browser is running. You must first"
            echo "close it, then execute this script and finally"
            echo "run it again to make changes effective."
        echo

else
    if [[ $(grep i <<< $1) ]]; then
        [[ $(grep "$PREFS_IMG" $PREFS_FILE) ]] || add "$PREFS_IMG"
        echo "Image loading is disabled"
    fi

    if [[ $(grep I <<< $1) ]]; then
        [[ $(grep "$PREFS_IMG" $PREFS_FILE) ]] && erase "$PREFS_IMG"
        echo "Image loading is enabled"
    fi

        if [[ $(grep j <<< $1) ]]; then
                [[ $(grep "$PREFS_JS" $PREFS_FILE) ]] || add "$PREFS_JS"
        echo "Javascript is disabled"
    fi

        if [[ $(grep J <<< $1) ]]; then
                [[ $(grep "$PREFS_JS" $PREFS_FILE) ]] && erase "$PREFS_JS"
        echo "Javascript is enabled"
    fi

        if [[ $(grep P <<< $1) ]]; then
                [[ $(grep "$PREFS_PLUG" $PREFS_FILE) ]] || add "$PREFS_PLUG"
                echo "Plugins are enabled"
    fi

        if [[ $(grep p <<< $1) ]]; then
                [[ $(grep "$PREFS_PLUG" $PREFS_FILE) ]] && erase "$PREFS_PLUG"
        echo "Plugins are disabled"
    fi
fi

# This script tends to add a lot of blank lines over the time.
# Removing them. Sed is my friendo. Sed is your friendo.
sed -ni '/..*/ p' $PREFS_FILE
edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
7 followers

Stats

Asked: 2014-01-23 23:53:40 +0200

Seen: 1,663 times

Last updated: Aug 04 '15