Posts: 1,228
secipolla
Joined: 15 Jun 2008
#1
Puppy has a nice little script called advert blocker, which downloads several hosts file lists, merges them and edits /etc/hosts.

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://www.murga-linux.com/puppy/viewtopic.php?t=59290"
linktext was:"http://www.murga-linux.com/puppy/viewtopic.php?t=59290"
====================================

It's very simple and has a gtkdialog interface.
gtkdialog is deprecated in Debian (uses zenity now) but even if it wasn't, for some reason the script as made for Puppy doesn't quite work with Debian (probably gtkdialog's differences).
So maybe Yves/lagopus, John/OU812 or some programmer (can you do it anti?) could adapt it to zenity and then it could even be included in antiX.
A plus would be make it with a dialog (the package) interface so it could be run from the command line.
Posts: 200
lagopus
Joined: 15 Oct 2008
#2
Tried to start the script
Bad variable substitution in strings like:

Code: Select all

<window title="'$title' '$appver'">
then on clicking the Start button, the script cannot find and execute the functions defined into the file.
The script allows to edit the /etc/hosts file without asking permission (that's puppy's world...)

I will try to have a look at this, if I get some time.
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#3
Oh well, actually I did remove any Puppy specific things but gtkdialog wouldn't work properly.
Regarding the /etc/hosts thing we just need to run it as root, of course.

If someday you manage to make it work it can be a nice little app and quite useful for antiX too. I don't know if you have any knowledge on this but a truly fast graphical interface is fltk2, which antiX already has because of dillo.
I've seen a guy at connochaet o.s. working on their tools with it.

The advert blocker script just downloads one to four different hosts lists, gets rid of duplicates, removes comments (not really necessary) and offers to append the resulting list to the current hosts file (or to replace its own previously generated list).
Posts: 200
lagopus
Joined: 15 Oct 2008
#4
Half done, secipolla
I will use zenity

There are 2 versions of gtkdialog around, hence your problems. I hate gtkdialog: I do not understand how it interacts with the shell, escaping strings and variable names is a nightmare, no documentation and the source code doesn't help...
Let's stay with zenity for simple interfaces; I use pygtk for more complex dialogs, without glade.
Some guys try to develop alternatives to zenity/gdialog/gtkdialog: autoglade, yad... still work in progress.

I never used fltk2, but I think it does not use native gtk widgets: I believe that consistency throughout the user interface is an essential goal.

Stay tuned
Posts: 200
lagopus
Joined: 15 Oct 2008
#5
Here is a candidate version of"antiX Advert Blocker"

Please try it and catch some bugs...
of course make a backup of your /etc/hosts file before

The tar contains the bash script

Update: flight deleted, updated
Last edited by lagopus on 19 Dec 2010, 16:00, edited 1 time in total.
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#6
Nice and quick. Thank you.
Needs one little fix that I caught. It generates a blank line above"# pup-advert-blocker IPs below" so at every edition of the file it creates a new blank line. Example:
Original file

Code: Select all

127.0.0.1    localhost
127.0.1.1    debian.casa    debian

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# pup-advert-blocker IPs below
{snip}
1st edition

Code: Select all

127.0.0.1    localhost
127.0.1.1    debian.casa    debian

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

# pup-advert-blocker IPs below
{snip}
2nd edition

Code: Select all

127.0.0.1    localhost
127.0.1.1    debian.casa    debian

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# pup-advert-blocker IPs below
{snip}
and so on.
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#7
Here's a sample advert-blocker.desktop file:

Code: Select all

[Desktop Entry]
Version=1.0
Name=Advert Blocker
Name[pt_BR]=Bloqueador de publicidade
GenericName=Advert Blocker
GenericName[pt_BR]=Bloqueador de publicidade
Comment=Save bandwidth and browse quicker by blocking ads from loading
Comment[pt_BR]=Navegue com mais rapidez e segurança bloqueando anĂșncios
TryExec=/usr/local/bin/block-advert.sh
Exec=block-advert.sh
Icon=dialog-error
Terminal=false
Type=Application
#StartupNotify=true
Categories=Utility;
-edit- removed 'gksu' from the Exec key as the script already calls it.
Posts: 200
lagopus
Joined: 15 Oct 2008
#8
Sergio:

made two corrections:
removed the empty line
and some lines that were not filtered
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#9
Thank you very much!
Seems to be working fine.
Posts: 1,228
secipolla
Joined: 15 Jun 2008
#10
Here's the Brazilian Portuguese translation, in case anti wants to use it.