PDA

View Full Version : Opera User Javascript is one more great feature.


Deacon
08-08-2006, 01:07:10
Let's say I use My Excite as my browser's startup page. I like most of the content, except for that one section titled "Excite Highlights". It's filled with ads and dumb celebrity news which will never interest me. This section does not have an "X" to get rid of it. So I'm stuck, right? Wrong.

For the domain "excite.com", I turned on User Scripts. Opera has built-in objects and methods to override variables, functions, events, etc. in Javascripts run by websites. In my UserJS directory, I put the following:

if(location.hostname.indexOf('excite.com') != -1)
{
window.opera.defineMagicVariable(
'nwMedia',
function ()
{
return 0;
},
null
);

window.opera.addEventListener(
'BeforeScript',
function (e)
{
e.element.text = e.element.text.replace(/Excite Highlights/g, '');
},
false
);
}


Reload the page, and it's gone. It's so much easier to destroy than to create. :)