What's new

AdBlocking with combined hosts file

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Just want to thanks the OP for this add blocker.
The only thing I miss is that I would love to see not loaded adds replaced by a fixed picture in order to see what was blocked.

What? If you see what was blocked, it wasn't blocked. :confused:
 
I want to say thank you to the creator of this Adblock script and the contributors! The advance script is working perfect on my N66U! Thanks! :)
 
Last edited:
Im using the advanced method on a rt-ac68U and rt-N66u. both hosts.blocked files look like this:

0.0.0.0 ad4.abradio.cz^M
0.0.0.0 a.abv.bg^M
0.0.0.0 adserver.abv.bg^M
0.0.0.0 adv.abv.bg^M
0.0.0.0 bimg.abv.bg^M
0.0.0.0 ca.abv.bg^M
and nothing is blocked. anyone know why it would be appending ^M to all the sites, or if that is even an issue?

edit: this method was working fine until the 56_2 update i believe.
 
The commands "sed $'s/\r$//'" in the script is what removes the ^M's from the downloaded block lists before sending them to hosts.blocked.

With the ^M's still there the blocking won't work.
 
Ok, so i got that straightened out on the RT-AC68U, but I'm still stuck on the RT-N66U. (56_2)

Basically what happens is that it'll create a temp file in /mnt/sda1/hosts/ and that file will contain the list like it should, but about half the time it'll stop. Running ./update-hosts.sh will just become unresponsive 50% of the time, and never create hosts.blocked. However, when it does 'complete' and creates the hosts.blocked file and deletes the temp, the hosts.blocked file will be empty.

I've tried using three different usb drives, I've tried plugging them into different ports, I've tried deleting the update-hosts.sh file and re-copying it. Nothing I do seems to work.

edit: ok, so, had a blank line at the end of whitelist.txt and blacklist.txt. removing those and rebooting fixed it.
 
Last edited:
Zekesdad:

1. Run the script in putty to see it pull from the various web sites. One of them is not responding, and for me the script would choke on it. Comment out or delete that one. There is a variation of the advanced method that builds $SourceA and $SourceB site by site, which makes it easy to comment out one that isn't working. Search in this thread.
2. An empty hosts.blocked, and a full temp file, is a result of an empty line in whitelist.txt. There are a couple of posts in this thread on this, and some lines of script to scrub the whitelist.txt to whitelist_clean.txt.

LonelyCoder:

The empty hosts.blocked happened to me after I updated my whitelist.txt, and it wasn't obvious what was happening. I wonder if you might find it worthwhile to adapt the advanced method with those scrubbing lines. Also using the $SourceA and Source B method, which is more readable, too. Awesome script.
 
Last edited:
Zekesdad:

1. Run the script in putty to see it pull from the various web sites. One of them is not responding, and for me the script would choke on it. Comment out or delete that one. There is a variation of the advanced method that builds $SourceA and $SourceB site by site, which makes it easy to comment out one that isn't working. Search in this thread.

How do I do that? Right now im connecting through FireSSH in firefox. wouldn't running the bash script in Putty give me the same output?

Im running ./update-hosts.sh in both, it doesn't show any outcome, except for the occasional "Done"
 
@zekesdad try to run the script in debug mode to see where it fails:
sh -x /jffs/scripts/update-hosts.sh

@elorimer I'll look into cleaning the whitelist asap.
 
I adapted a couple of lines from post #398 to change whitelist.txt to whitelist_clean.txt, fed that to the whitelist scrub then deleted whitelist_clean.
 
I would love to try this myself, but is this as step by step as can be?

I'm not usually as dumb as I feel when I look at post #1, but I really don't know where to begin to get this going on my RT-N66U with the RMerlin 374.39_0-em firmware installed.

Any baby steps walkthrough for a coding newbie?

If only there was a Merlin fork that built this in...
 
I'm having trouble getting the advanced method to work. RT AC68 with John's latest fork V15E5. I have WinScp configured and working, also Putty and Notepad++. Can someone please give a more detailed explanation on how to get the scripts to run? I have made the required directories but how do I put the scripts in? What I did was copy and paste the code into NP++, ensured EOL conversion was in unix format and now I'm stuck. What name do I give each script?
 
well, for example, the services-start script would be a file called services-start and you would place it in /jffs/scripts/ folder


as far as "getting them to run" the

chmod a+rx /jffs/scripts/*

command makes them "executable".
 
well, for example, the services-start script would be a file called services-start and you would place it in /jffs/scripts/ folder


as far as "getting them to run" the

chmod a+rx /jffs/scripts/*

command makes them "executable".

Thanks for the response, zekesdad.

I have a folder /jffs/scripts/services-start and I copied the file and named it services-start. In WinScp I right click on the script , select custom commands and execute to see it run. The progress bar does not leave 0% complete then the dialog box closes a few seconds later.

I have issued the chmod command, but where should it do it from ? In /temp/home/root# or in /jffs/scripts/services-start?
 
You should have had two folders set up by default

/jffs/scripts
/jffs/configs

If you didn't have these when you first looked, you should select reformat at next boot and start over.
(copy your scripts out using WinSCP to another location to save)

then within the /jffs/scripts folder, you make the scripts, simply named

services-start
update-hosts.sh

and in /jffs/configs, the file

dnsmasq.conf.add


then, issue the command

chmod a+rx /jffs/scripts/*
 
Thanks for the response, zekesdad.

I have a folder /jffs/scripts/services-start and I copied the file and named it services-start. In WinScp I right click on the script , select custom commands and execute to see it run. The progress bar does not leave 0% complete then the dialog box closes a few seconds later.

I have issued the chmod command, but where should it do it from ? In /temp/home/root# or in /jffs/scripts/services-start?
anywhere will work because the command is telling it where to change the attributes.
 
anywhere will work because the command is telling it where to change the attributes.
Thanks for that, clears one more thing up for me.

Now regarding the scripts in NP++, what is the correct file extension to save as? I see lots of choices like "*", *txt, and a unix script file. I do have EOL set to unix.
 
Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top