Announcement

Collapse
No announcement yet.

Script to automate building an adblocking hosts file

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SecretCode
    replied
    What directory did you save the script in? Home, I'm guessing, and also guessing that's not in your PATH.

    If you put it in ~/bin it will get found. (After you start a new shell - one of the bash initialisation scripts add ~/bin to your path if it exists.)

    Leave a comment:


  • Snowhog
    replied
    Just created SR's script and ran it and replaced my /etc/hosts file accordingly. Rebooted. Browsing does indeed seem more responsive - snappier. Cool.

    Note: I at least, could not execute the script by just typing gethosts. Kept getting "gethosts: command not found". Executing it with
    Code:
    ./gethosts
    works.

    Leave a comment:


  • SteveRiley
    replied
    Nope. I plan to add the extra functionality discussed here: KDialog and an easy-on-off mechanism at least. A relatively simple tailoring mechanism like what you described earlier shouldn't be too difficult, either.

    Alas, it's easy to get distracted! I have some air travel coming up, and Alaska Air has wi-fi on all planes now, so perhaps I can put those five hours on SEA-DCA to good use, eh?

    Leave a comment:


  • oshunluvr
    replied
    Have you updated this one lately?

    GG's intergalactic hitchhiking not withstanding of course...

    ...don't forget your towel Jerry!

    Leave a comment:


  • SteveRiley
    replied
    Originally posted by GreyGeek View Post
    (I hadn't noticed that "two hour" thing last November...)
    Ah... I thought maybe you had meant to reply to some other thread here on the board!

    Leave a comment:


  • GreyGeek
    replied
    Ya, I'll get over it. Just a small case of brain envy!

    (I hadn't noticed that "two hour" thing last November...)

    Leave a comment:


  • SteveRiley
    replied
    Uh...Jerry? You OK?

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by SteveRiley View Post
    ....
    So I've spent the last couple hours teaching myself bash scripts and especially the handy little sed utility. ...
    A couple hours, eh?

    Tell me again what planet you are from .... I forgot!

    Thanks for the fish!!! I'm going to eat it!

    Leave a comment:


  • rms
    replied
    Jeez, I was not aware that adblock+ was eating so much RAM... thanks for the script Steve. +1

    Leave a comment:


  • oshunluvr
    replied
    Re: Script to automate building an adblocking hosts file

    In my case - I'm using multiple host files tailored to the user and creating a login-time host file based on individual users. I use a base file called hosts.local and then each user has .hosts.bad in their home. At log in the .local file is added to the .bad file as /etc/hosts.

    The nice thing about moblock is being able to turn it off when needed. The above method makes it more difficult. However, I like that it doesn't use ram or cpu time.

    Leave a comment:


  • GreyGeek
    replied
    Re: Script to automate building an adblocking hosts file

    I forgot to include the link to the Kdialog Tutorial


    Click image for larger version

Name:	table2.png
Views:	1
Size:	249.0 KB
ID:	640383
    Last edited by Snowhog; Jun 12, 2013, 12:06 AM.

    Leave a comment:


  • SteveRiley
    replied
    Re: Script to automate building an adblocking hosts file

    Originally posted by GreyGeek
    Perhaps a kdialog gui and also include the option to
    temporarily disable the blocking hosts file (sudo mv, then sudo mv back)
    to allow clicking some links in email?
    Hey, I like that idea -- using the GUI for the interactive portions of the script. Dunno why, but I was originally going to stick with something in text mode. Seems kinda silly now that I think about it!

    Leave a comment:


  • GreyGeek
    replied
    Script to automate building an adblocking hosts file

    Originally posted by SteveRiley
    ....
    Besides the VM integration, is there anything else you'd like to see?
    The wgets are very fast and the sed command is completed in under a second on my box, leaving a file with 30,328 blocked entries.

    What you have is, for most people, pretty inclusive. It is for me, anyway.

    Perhaps a kdialog gui and also include the option to
    temporarily disable the blocking hosts file (sudo mv, then sudo mv back)
    to allow clicking some links in email?

    Code:
    Usage: kdialog [Qt-options] [KDE-options] [options] [arg] 
    
    KDialog can be used to show nice dialog boxes from shell scripts
    
    Generic options:
     --help          Show help about options
     --help-qt         Show Qt specific options
     --help-kde        Show KDE specific options
     --help-all        Show all options
     --author         Show author information
     -v, --version       Show version information
     --license         Show license information
     --            End of options
    
    Options:
     --yesno <text>      Question message box with yes/no buttons
     --yesnocancel <text>   Question message box with yes/no/cancel buttons
     --warningyesno <text>   Warning message box with yes/no buttons
     --warningcontinuecancel <text> Warning message box with continue/cancel buttons
     --warningyesnocancel <text> Warning message box with yes/no/cancel buttons
     --sorry <text>      'Sorry' message box
     --error <text>      'Error' message box
     --msgbox <text>      Message Box dialog
     --inputbox <text> <init> Input Box dialog
     --password <text>     Password dialog
     --textbox <file> [width] [height] Text Box dialog
     --textinputbox <text> <init> [width] [height] Text Input Box dialog
     --combobox <text> item [item] [item] ... ComboBox dialog
     --menu <text> [tag item] [tag item] ... Menu dialog
     --checklist <text> [tag item status] ... Check List dialog
     --radiolist <text> [tag item status] ... Radio List dialog
     --passivepopup <text> <timeout> Passive Popup
     --getopenfilename [startDir] [filter] File dialog to open an existing file
     --getsavefilename [startDir] [filter] File dialog to save a file
     --getexistingdirectory [startDir] File dialog to select an existing directory
     --getopenurl [startDir] [filter] File dialog to open an existing URL
     --getsaveurl [startDir] [filter] File dialog to save a URL
     --geticon [group] [context] Icon chooser dialog
     --progressbar <text> [totalsteps] Progress bar dialog, returns a D-Bus reference for communication
     --getcolor        Color dialog to select a color
     --title <text>      Dialog title
     --default <text>     Default entry to use for combobox, menu and color
     --multiple        Allows the --getopenurl and --getopenfilename options to return multiple files
     --separate-output     Return list items on separate lines (for checklist option and file open with --multiple)
     --print-winid       Outputs the winId of each dialog
     --dontagain <file:entry> Config file and option name for saving the "do-not-show/ask-again" state
     --slider <text> [minvalue] [maxvalue] [step] Slider dialog box, returns selected value
     --calendar <text>     Calendar dialog box, returns selected date
     --attach <winid>     Makes the dialog transient for an X app specified by winid
    
    Arguments:
     arg            Arguments - depending on main option
    Examples are here.

    Leave a comment:


  • SteveRiley
    replied
    Script to automate building an adblocking hosts file

    Originally posted by oshunluvr
    I found an app called MoBlock which I've just begun playing with. Cross-platform and auto-updating and uses Blue Tack's hosts list or any others you want to config
    Interesting...it appears the project stopped a while ago, and the work is transitioning to a Linux version of PeerGuardian. I've PG on Windows, didn't even think to check whether there was a Linux version.

    And, alas, Bluetack is having some problems staying afloat...

    Originally posted by oshunluvr
    As far as Steve's tool - Add different settings for different users. As in: allow the adults to see 18+ sites, but the kids can't, everyone get ad-blocking, and Mom (for some strange reason) can't log into any shopping sites...<chuckle>
    That's a lot easier to do with browser plug-ins like AdBlock because those tools rely on lists of regular expressions. I'd have to search for hosts file lists that differentiate between 18+ sites and also add some form of authentication awareness into my script so it knows who's logged into the box.

    Leave a comment:


  • oshunluvr
    replied
    Script to automate building an adblocking hosts file

    Not to crap on Steve's parade, I found an app called MoBlock which I've just begun playing with. Cross-platform and auto-updating and uses Blue Tack's hosts list or any others you want to config. Worth looking at.

    As far as Steve's tool - Add different settings for different users. As in: allow the adults to see 18+ sites, but the kids can't, everyone get ad-blocking, and Mom (for some strange reason) can't log into any shopping sites...<chuckle>

    Leave a comment:

Working...
X