1

I want to block images in a website which is often unimportant ads uploaded to their server or host.

Using inspect element I noticed the all these images was named with ad-[some number].jpg.

I can’t use any extensions in my browser so is it possible to do something like that using the “hosts” file or any local way.

I have tried ad-*.jpg but it doesnt make any sense.

Giacomo1968
  • 58,727

3 Answers3

1

I want to block images in a website....so how could i do that using hosts file or any local way.

The Hosts file won't work for you. It blocks everything served by a server.

The HOSTS file enables you to change the IP address your computer uses to connect to certain hosts. For example the following entry:

www.example.com       127.0.0.1

will cause your computer to direct all connections targeting the Internet host www.example.com to 127.0.0.1.

However, what you're trying to do is block requests for resources on the Internet host, such as www.example.com/ads/somead.jpg, without blocking other content on the host. This cannot be done with the Hosts file; it's all or nothing.

I can't use any extensions

Bummer.

It's no good that the solution to your problem is to use browser extensions like AdBlock Plus. That's really the best approach when trying to implement something on your local machine to block unwanted ads.

If you happen to have control of the router that serves your network, it may have some options for blocking unwanted content at the network level.

0

I know this is quite late to the game but Proxomitron, though no longer supported, author passed away, rewrites html on the fly to eliminate ads and unwanted content. You can even replace code with your own. Minorly functional with ASP and PHP pages.

-2

You can do it with hosts file by mapping a hostname to localhost but you need to know what server's hostname is requested to display these ads. I would suggest to use Ad block software which would do the job better.

Anyhow if you manage to get ad server hostname or ip you just have to do as I said above :

/etc/hosts:

ad_server's_hostname localhost
ad_server's_ip       localhost
jehutyy
  • 292