Innuendo and out the other

About Opera and stuff

Content blocking in Opera 9 Technology Preview 2

, , ,

This post is a tutorial on how to use the content block feature introduced in Opera 9 Technical Preview 2. The feature is work-in-progress, but the Technical Preview will let you have a taste of how it works and make us gather feedback for future improvements.

Opera has had a feature that would let you block certain paths, protocols or servers for a long time. This feature has been configured using the "filter.ini" file and mostly used in kiosk mode or with third party tools. Documentation for this feature is part of the kiosk documentation found here.

The new content block feature in Opera 9 TP2 is based on the existing functionality that has been in Opera for a long time, but adds an easy-to-use user interface for maintaining this file.

To enable the feature, you need to set the page in "content block mode".

When you select the "Block content..." menu entry, the page will go into "content block mode". When the page is in this mode, all content that can be blocked (images and plugins) will appear normal, while text and other content will be greyed out.

You can now click on all the content you want to block and it will be added to the list of blocked content. Images and plugins will be drawn with a clear sign overlaid on the content when it is blocked.

A toolbar will be available when the page is in content block mode that will let you save, cancel or edit the filters that has been created so far.

If you press the "Details..." button, you will be able to edit the pattern Opera has created automatically to block content coming from the same path on the webserver.

As you can see, Opera has already created a pattern with a * wildcard to block all content that is loaded from the path starting at "http://portal.opera.com/img/". You may edit, delete or add new manual paths to be blocked in this dialog. * will match anything and ? will match a single character.

When you are done selecting the content to block, press "Done" in the toolbar.

If you would like to edit and delete all the paths to content that is currently being blocked by Opera, you may use the menu entry Tools->Advanced->Blocked content...


When you later load a webpage that contains blocked content, this content will not be loaded from the server and will be collapsed on the webpage.

Some changes have been made lowlevel compared to how the existing filter.ini filtering used to work:

- URLs are initially filtered in the layout engine and Opera will not attempt to load blocked content from the server. The layout engine will collapse the blocked content using the equivalent of the CSS "display: none".
- Lowlevel blocking of complete sites will still occur, so the existing functionality of filter.ini has not been changed. This could eg. be used to create rudimentary parental filters too.
- The default name for the configuration file is "urlfilter.ini" and if you have added content to block using the user interface, there is no need to configure a file or create a file.

About this blogThumbnails in Opera 9 Technology Preview 2

Comments

CoreRouter Tuesday, February 7, 2006 10:04:35 AM

Thats a really nice feature ..

Have been using Opera since Version 5 and now "I'm loving it (tm)"

:-) great work, keep going

greets from germany
Jan

kloned Tuesday, February 7, 2006 12:30:11 PM

COOL! But can I block explicitly image on the top-right corner (Linda Evangelista) of this blog: http://lofotenmoose.info/-/item/opera-internals-quietly-conservative, аnd others like this one ?

Non-Tropponon-troppo Tuesday, February 7, 2006 2:24:19 PM

kloned: that image is specified in CSS, so you'd need to maually add it, I assume the rule will apply to any download content, whether it be specified in HTML or CSS.

kloned Tuesday, February 7, 2006 2:53:06 PM

non-troppo -> It will be great, because this is a way to avoid Opera's content blocking feature.

LeoPetr Tuesday, February 7, 2006 6:23:40 PM

Should the "Block Content..." command also be present on the context menu when right-clicking on an image or an object? Only placing it on the context menu for text is entirely contrary to the way Adblock works in Firefox and perhaps contrary to intuition.

Leo

LeoPetr Tuesday, February 7, 2006 6:30:34 PM

This is a major, terrifically implemented feature. It should also have a home in the main menu or the toolbar. I would recommend the Eyeglasses View Bar as the ideal location -- BTW, what's Voice doing there? :)

Simon Houstonshoust Wednesday, February 8, 2006 12:25:18 AM

My suggestion for it would be that when clicking on images/objects in a page, the url relating to that object should be blocked, and if you can happen to click the entire page or maybe iframes contents for example, the actual server itself will be blocked too.

Petter Nilsenmitchman2 Wednesday, February 8, 2006 1:33:58 AM

Blocking an entire server can be dangerous as the user wouldn't necessarily know why a page doesn't load. Would need safeguards there.
hmm.

jesus2099 Wednesday, February 8, 2006 4:54:59 PM

Thank you SO very much for having put a simple way to edit this filter.ini (or whatever equivalent urlfilter.ini) file at last!

If this makes it through Opera 9 version I may be able to get rid of Proxomitron or manual filter.ini editing or anyother method I had to use but was insatisfied with!

coffee

Stefansguen Thursday, February 9, 2006 1:17:16 AM

Awesome feature! My questions is: Woudn't it slow down the rendering of the pages, especially if there are a lot of blocked content?

chaimav Thursday, February 9, 2006 4:14:43 AM

I would it assume it would speed up loading of pages, less to download and less to render.

Simon Houstonshoust Friday, February 10, 2006 3:53:48 PM

Another suggestion, would it be possible to refresh the look of the page after content block mode has been done? Because when you click Done it feels like nothing has been blocked at all.. until you reload that page of course smile

Petter Nilsenmitchman2 Saturday, February 11, 2006 1:59:22 AM

Yes, it does that now, but it doesn't handle iframe's etc. very well. It will be improved.

jesus2099 Monday, February 13, 2006 4:53:46 PM

It is impossible to click on flash content without triggering the animation's link. I have to look for the URL manually in the source.
It does not bother me this mush though as I prefer looking to the source to block the javascripts that write he flash usually.

It's just a suggestion: idea To be able to select a flash object to block by some way.

Oh yes I have another question. On my poor old modem I really appreciate the time I gain by blocking heavy ad contents.
My urlfilter.ini is getting bigger and bigger (http://jesus2099.free.fr/fichiers/urlfilter.ini). Maybe a big list would slow down Opera as it would have to test lots of URL matching? confused

Petter Nilsenmitchman2 Monday, February 13, 2006 5:05:44 PM

Do you click the flash while in content block mode? No navigation should be triggered then. If it does, please provide a URL to a page I can test with.

A big urlfilter.ini will not necessarily increase loading speed as the content it blocks will not be loaded, thus saving speed in that area.

jesus2099 Friday, February 17, 2006 1:38:22 PM

smile Hello Petter!

I don't remember which ones I encountered but You're right, I came to http://www.laposte.net and I was able to click and block.

But I remember clearly that every and each SWF I encountered untill now would navigate if I click on it with content block mode on.

Here is an example. It is not an ad, it's my radio. But, when you are in content block mode, when you click on it, it starts/stops the songs etc. It does not block/unblock the URL.

http://jesus2099.free.fr/radio/

Petter Nilsenmitchman2 Sunday, February 19, 2006 1:40:43 AM

Yes, to be able to block a flash with the method we use, the flash needs to initiate a navigation to a different page. In the case you mentions, this doesn't happen and it can't currently be blocked by clicking on it.

jesus2099 Saturday, February 25, 2006 11:15:23 AM

Oh I understand now!
Thank you all Opera dudes, I really think you are great!

Danny GuzmanSMF Saturday, March 11, 2006 6:04:16 PM

I love this blog. I have been using Opera since version 6.0
I can't believe all the cool things Opera 9.0 Preview 2 has.
I was drawn in by the new content blocking feature but when I installed my Opera 9 about 2 weeks ago I had no idea where to look. So, today now that I have time I fired up my 9 and went looking for answers. Thanks for explaining all the new features Petter. I now have the Opera content blocking feature figured out and it is brilliant.
Now I can move on and read about the widgets and everything else you have posted here. This is very exciting. I don't have to tell you guys to keep up the good work. You guys rule!

SMF

Danny GuzmanSMF Saturday, March 11, 2006 6:39:25 PM

Well the content blocking feature worked once and now I try to use it just for testing purposes and when I click on the content blocking button it only brings up the larger window to add content but not the slim browser tool bar that allows me to click on images sad This needs a fiz or a serious short cut button next to the Authot Mode/Show Image/Fit to windows width section.

Danny GuzmanSMF Saturday, March 11, 2006 7:23:10 PM

The fact that the tool bar hides its self and reverts back to hidden mode totaly blows this content blocking feature. I have to do a song and dance to get that tool bar to show and I have to do it over and over and over which is a huge waste of time. This slim tool bar
[img]http://img64.imageshack.us/img64/1184/snaps0186ul.jpg
The fact that it insists in hidding it's self and I can not dock it any where I choose blows.
Fix this please smile lol

Danny GuzmanSMF Sunday, March 12, 2006 1:33:06 AM

I finaly figured out that I can dock the Done/Cancel/Details buttons from the content blocker onto my my main bar. I had to reconfigure my settings but I guess that is what it will take to make my browser set to my own comfort level.
In closing. With Opera I can.

Opera Rules

Again thanks for your blog with explinations it has been very helpful.

Oh and sorry I was complaining to you.
I should know better as Opera has never failed me yet.

kernelm Friday, March 24, 2006 7:57:24 AM

Will future version of the content blocker support regular expressions? It'd be great to be able to import the Adblock filter sets that are available.

jesus2099 Friday, April 7, 2006 11:07:04 AM

I don't see any advertising any more ; What a relief!
Here are my filters with french explanations here: http://jesus2099.free.fr/blog/2006/02/bloquer-les-publicits-dans-opera.html

Follow the link to urlfilter.ini (down the page) to download.

Petter Nilsenmitchman2 Friday, April 7, 2006 2:55:15 PM

@kernelm: No specific plans for full regular expression support yet, but we'll see. You can use * to match multiple characters or ? to match just a single character.

etherealsilence Monday, April 10, 2006 11:55:14 PM

@mitchman2 re: regular expression support

If I may ask, why in the world WOULDN'T you add support for regular expressions? Nearly every major programming language has great libraries for regular expression support. I know that what seems like a trivial task to an outsider can often be a big pain, but in this case, I'm having trouble believing that it would be that hard to implement.

Having integrated regular expression support into several of my own projects (admittedly much, MUCH smaller than opera), I can say that it's a pretty painless process. The benefit gained would be huge for Opera, and the time cost should be very low. I know several holdouts in the firefox camp that won't switch because of the lack of regular expression support for filtering. The ability to import a good list like filterset.g (http://www.pierceive.com/filtersetg/) would be incredible. Please, PLEASE push for regex support. Many users beg you.

As for the improvements mentioned in the post above? Beautiful. Keep up the good work.

Petter Nilsenmitchman2 Tuesday, April 11, 2006 3:30:52 PM

We will need to consider overhead and backwards compatibility as the filter.ini mechanism has been in Opera for a long time. I won't rule out regexp support, but filter.ini would change and all the rules would need to change.
It's trivial to implement regexp, but not trivial for a normal user to add manual rules or having to consider backwards compatibility.

Jonathan ShareSharebear Tuesday, April 11, 2006 3:47:48 PM

etherealsilence: filter.ini needs to be accessible by (power)users who are not necessarily programmers. For these people having the power of regex is overkill and possible too much of an obstacle for non-programmers to understand. Do you see any way we could integrate regex but still keep the file easy to understand for non-programmers ?

GrahamGort Friday, April 21, 2006 11:39:32 PM

Good to see this feature added to Opera. However, may I suggest that content blocking can be enabled and disabled in the Edit Site Preferences dialogue box. There might be some sites were you might want the content you blocked on a global basis to be shown just for a particular site.

etherealsilence Thursday, April 27, 2006 9:01:00 PM

@mitchman2 & Sharebear

The simplest solution is almost always the best. In this case, don't force anyone to use regular expressions... leave the current filtering alone. Just ADD support for regexp.

I'd suggest something simple, like preceding all regular expression filters in the filter.ini file with an "@" char.

If filter.ToCharArray()(0) == '@'
{
ParseRegExpFilter(filter)
}
Else
{
ParseNormalFilter(filter)
}

Can't get much simpler than that. Regular users don't even have to know that it's there. Just include a note somewhere in the help file or even just a sticky in the forums letting the power users know that the support for it is there.

intelbill Tuesday, May 16, 2006 3:20:02 AM

that is great things

hikingpete Friday, June 2, 2006 6:10:46 PM

My favourite feature from FireFox's Adblock extension is the ability to block JavaScripts. JavaScripts are unfortunately difficult to click on, so what that plugin does, is have a list of blockable content, which you can sort by type (HTML Tag). I would love to see such an easy way of blocking JavaScripts in Opera.

As for Regular Expressions, what the Adblock extension in Firefox does, is to simply consider anything beginning with a forward slash (/) a regular expression, other patterns are interpretted with normal wildcards. Honestly, I can't think of any normal pattern (in the context of URLs) that begins with a forward slash. Of course, I can't claim to fully understand the problem, but I also much covet the possibility of using Filterset.G.

Thanks for the great work.

jesus2099 Thursday, October 19, 2006 8:34:18 AM

I am a fanatic user of blocked content ! It is SO great.
A usefull addition would be a nice [on|off] toggle in the F12 popup menu or in the site preferences !

Flavio SuárezYinYanger Thursday, October 19, 2006 11:08:26 AM

I agree!
It would be very useful, as I use an always updated list from http://pgl.yoyo.org/adservers/

jesus2099 Thursday, October 19, 2006 7:02:08 PM

This list also includes statistic counters.
I prefer blacklisting only ads because I want to support Opera and let it shows in every statistics I can. smile
This is my list with only ads : http://jesus2099.free.fr/blog/2006/02/bloquer-les-publicits-dans-opera.html (Yes, again. Sorry)

Flavio SuárezYinYanger Friday, October 20, 2006 11:58:42 AM

Can you give an URL sample, for test? Thanks!

Gingerbread Guy Friday, October 27, 2006 3:53:47 PM

I'd like to take this opportunity to beg for RegExp support alongside everyone else who requested it. Not being able to use Filterset.G is the main reason I'm sticking with Firefox. I've tried ad filter lists but they bloated Opera so much that it took several minutes to start. They were 150k on average, whereas Filterset.G is about 5k. Please, please add support for it in the not-too-distant future.

Happy Halloween!

chosig Tuesday, May 29, 2007 5:18:40 PM

would be really nice to be able to block content on a tag basis, ie. a specific <div> for instance

ir čia priėjo, Saulius :)einu Saturday, April 19, 2008 12:43:32 PM

this sucking smile block content via edit or details..to add custom url DONT RECOGNIZES AND DO NOT SUPORT as i tryed and it just forgets what I'm typed
example:
https://g.adspeed.net*
https ????? and = zero emotions to opera... SADDDDD rly SAAAD

jesus2099 Wednesday, March 25, 2009 11:23:09 AM

My content, for instance, doesn't include advertisement.
I am not blocking my own content and I'm very happy to block all the ads.
Without this feature I would still be using proxomitron.
What do you mean, Filip007 ?

Kerwin Codotker Tuesday, October 20, 2009 7:43:48 AM

Thanks for the helpful guide I use adblock most of the time it does save a hell of a bandwidth but some sites won't load.

So how do i exclude those sites from being blocked?

Petter Nilsenmitchman2 Thursday, October 29, 2009 2:59:56 AM

Right click the page on such a site->Edit site prefs and disable the content blocker on the site.

Kerwin Codotker Friday, October 30, 2009 11:50:43 AM

Thanks a lot mitchman, see it now. Where are these settings stored by the way?

jesus2099 Saturday, October 31, 2009 9:18:12 AM

urlfilter.ini in your Opera profile folder.

LyovBlindWatcherX Saturday, January 16, 2010 9:21:29 AM

Thanks, really helped me on blocking some annoying pictures smile

aegide Friday, June 25, 2010 10:34:47 AM

Hi all,
@chosig: for blocking div's etc i use the site specific stylesheet blocking. it's not that big of a deal to just create a .css-File with a

divid { display: none; }

in it. Works great for me. i only use it for regularly visited sites though, all others i use proxomitron whenever need be.
cheers

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.