Skip navigation.

Using block content to disable scripts

This is more of a working hack because block content works with images etc.
I made changes to the contentblock.css file so I could include my own "bar" with script images at the top of the page.

And I made a userjs to list the scripts faked as images in that bar, so when clicking them, opera's block content feature actually blocks it.

contentblock.css

Scriptblock.js

By default, the bar is always on, as you can hover over the items to see their addresses, however its not possible for me to show the addresses before blocking them in blocked content(css hover doesn't work, neither does mouseoever/out events). So be careful what you block.

If you want the bar hidden by default, replace line 7, shown below:

scriptslist.style='display:block;position:fixed;top:0;left:0;max-height:62px;overflow:auto;background-color:beige;border:1px dotted black;width:100%;font-size:10px !important;z-index:9999 !important';


with this:

scriptslist.style='display:none;position:fixed;top:0;left:0;max-height:62px;overflow:auto;background-color:beige;border:1px dotted black;width:100%;font-size:10px !important;z-index:9999 !important';


Enjoy :smile:

EDIT: Changed it so the image alt is shown, and if there are many scripts, there is a scroll list.

Change address in almost any IE window(anything that uses IE's engine)This is why there should be no war.

Comments

A.Ruzanov 16. January 2009, 12:52

Interesting, thanks.

its not possible for me to show the addresses


Add address in alt? It's work.

var scriptz=[];
opera.addEventListener('BeforeExternalScript',

Hmm.. Why not simple «document.getElementsByTagName('script')»?

Simon Houston 16. January 2009, 14:01

@lex,no hover effects work at all in block content mode, not even mouseover.
Also getting scripts from DOM doesn't always work, eg whole page could be rewritten without script tags.

A.Ruzanov 16. January 2009, 14:17

no hover effects work at all


http://files.myopera.com/Lex1/files/block.png

DOM doesn't always work


Maybe, but this method wrong work on http://operafan.net/forum/.
On page is 5 scripts
http://operafan.net/forum/Themes/default/script.js?fin11
http://operafan.net/forum/Themes/default/sha1.js
http://pagead2.googlesyndication.com/pagead/show_ads.js
http://googleads.g.doubleclick.net/pagead/test_domain.js
http://pagead2.googlesyndication.com/pagead/show_ads.js

but shows only 3.

Simon Houston 17. January 2009, 22:40

Ok, I've decided to do it your way instead, and changed font size to 10px to fit more scripts in, and added a scroll if there are more scripts. I don't think there is a way to detect is something is blocked during block content mode though.

Phred 18. January 2009, 20:27

Originally posted by shoust:

no hover effects work at all

would this include css hover effects?
.stuff:hover:before { content: attr(alt) } 

Originally posted by shoust:

I don't think there is a way to detect is something is blocked during block content mode though.

BeforeExternalScript doesn't fire for blocked elements... if i remember correctly. That would explain the counts being off.

A.Ruzanov 14. April 2009, 12:49

Scriptblock.js breaks http://maps.google.com (sample).

Dragon2fly 21. August 2009, 15:36

Do these script work as your BlockIt.
Do I have to download contentblock.css & Scriptblock.js together?
If I have to use 2 of them, how can I install contentblock.css?


Simon Houston 21. August 2009, 17:36

You save the file over the current one, most likely in your profile > styles folder, or opera folder > styles

Dragon2fly 23. August 2009, 02:40

Thanks for your direction.

This script is very cool! Some flash are also advertisements. Could the bar shows the link to flash, too?

Write a comment

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