Operaised -- The blog

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)Making specific buttons hide when not needed.

Comments

A.RuzanovLex1 Friday, January 16, 2009 12:52:36 PM

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 Houstonshoust Friday, January 16, 2009 2:01:34 PM

@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.RuzanovLex1 Friday, January 16, 2009 2:17:19 PM

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 Houstonshoust Saturday, January 17, 2009 10:40:32 PM

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.

MyOpera team, please fix this!fearphage Sunday, January 18, 2009 8:27:54 PM

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.RuzanovLex1 Tuesday, April 14, 2009 12:49:52 PM

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

Dragon2flybachhoakhai Friday, August 21, 2009 3:36:11 PM

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 Houstonshoust Friday, August 21, 2009 5:36:09 PM

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

Dragon2flybachhoakhai Sunday, August 23, 2009 2:40:27 AM

Thanks for your direction.

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

G.SandlerCreat0R Tuesday, September 7, 2010 2:42:19 AM

Shoust
Hi,

Can you please add a header to the script, something like that:

// ==UserScript==
// @Name Script Block
// @Author Shoust
// @Version 1.0
// @Description Script Block using Content Block
// @ujs:download http://files.myopera.com/shoust/blog/Scriptblock.js
// ==/UserScript==


Because my UserJS Manager have a feature to update scripts, and this script can not be updated properly without the header (@version and @download is requierd).

Thanks.

Write a comment

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