Skip navigation.

exploreopera

| Help

Sign up | Help

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

avatar
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

By CoreRouter, # 7. February 2006, 10:04:35

avatar
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 ?

By kloned, # 7. February 2006, 12:30:11

avatar
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.

By non-troppo, # 7. February 2006, 14:24:19

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

By kloned, # 7. February 2006, 14:53:06

avatar
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

By LeoPetr, # 7. February 2006, 18:23:40

avatar
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? :)

By LeoPetr, # 7. February 2006, 18:30:34

avatar
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.

By shoust, # 8. February 2006, 00:25:18

avatar
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.

By mitchman2, # 8. February 2006, 01:33:58

avatar
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:

By Ti, # 8. February 2006, 16:54:59

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

By sguen, # 9. February 2006, 01:17:16

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

By chaimav, # 9. February 2006, 04:14:43

avatar
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:

By shoust, # 10. February 2006, 15:53:48

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

By mitchman2, # 11. February 2006, 01:59:22

avatar
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:

By Ti, # 13. February 2006, 16:53:46

avatar
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.

By mitchman2, # 13. February 2006, 17:05:44

avatar
: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/

By Ti, # 17. February 2006, 13:38:22

avatar
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.

By mitchman2, # 19. February 2006, 01:40:43

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

By Ti, # 25. February 2006, 11:15:23

avatar
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

By SMF, # 11. March 2006, 18:04:16

avatar
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 :frown: This needs a fiz or a serious short cut button next to the Authot Mode/Show Image/Fit to windows width section.

By SMF, # 11. March 2006, 18:39:25

avatar
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

By SMF, # 11. March 2006, 19:23:10

avatar
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.

By SMF, # 12. March 2006, 01:33:06

avatar
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.

By kernelm, # 24. March 2006, 07:57:24

avatar
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.

By Ti, # 7. April 2006, 11:07:04

avatar
@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.

By mitchman2, # 7. April 2006, 14:55:15

avatar
@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.

By etherealsilence, # 10. April 2006, 23:55:14

avatar
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.

By mitchman2, # 11. April 2006, 15:30:52

avatar
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 ?

By Sharebear, # 11. April 2006, 15:47:48

avatar
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.

By Gort, # 21. April 2006, 23:39:32

avatar
@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.

By etherealsilence, # 27. April 2006, 21:01:00

avatar
that is great things

By intelbill, # 16. May 2006, 03:20:02

avatar
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.

By hikingpete, # 2. June 2006, 18:10:46

avatar
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 !

By Ti, # 19. October 2006, 08:34:18

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

By YinYanger, # 19. October 2006, 11:08:26

avatar
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)

By Ti, # 19. October 2006, 19:02:08

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

By YinYanger, # 20. October 2006, 11:58:42

avatar
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!

By Gingerbread Guy, # 27. October 2006, 15:53:47

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

By chosig, # 29. May 2007, 17:18:40

avatar
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

By soul.., # 19. April 2008, 12:43:32

Write a comment

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