halO

programming, hackery, rants, science and of course Opera

I'm so tired of slow ads

, , , , ,

Many ads are added by just linking an external script to the page. I'm going to show you how to stop all scripts that are not originating from the domain you are currently visiting.

Copy the code below, save it to a file 'prevent_all_external_scripts.js' and add it to a folder. I call my folder 'userjs' and is placed in my documents.

window.opera.rx295723629 = new RegExp('^http:\/\/([a-zA-Z0-9\u0080-\u00ff-.]*)?'+location.hostname);
window.opera.addEventListener(
 'BeforeExternalScript',
 function (e) {
   var src = e.element.getAttribute('src');
   if(src.match(/^http:\/\//) && !src.match(window.opera.rx295723629)){
      opera.postError('Script outside '+location.hostname+' was found and blocked: '+src);
      e.preventDefault();
   }
 },
 false
);

Open Tools->Preferences->Content->Javascript Options and add the folder to the text box at the bottom, where it says "User Javascript Files".

Now any site you are visiting will load scripts originating from the current domain, but ignore external scripts.

Backup Operas autosaveOpera Adblock

Comments

victordecimal Tuesday, July 29, 2008 11:34:07 PM

Man, you're my hero. Thank you for the solution, and by all means, thank you to make it greatly indexed by google, by putting opera slow ads in a same title smile

Adrianapa240 Wednesday, July 30, 2008 1:11:40 AM

This is perfect. It's so much better than try to use a url filter which sometimes blocks things I need. This has made Opera almost perfect for me.

Anonymous Friday, August 1, 2008 7:47:08 PM

stroh writes: I think I love you.

GregLand Monday, September 15, 2008 12:08:11 PM

Perfect !!!!
Nice Script...

Magne omflug Sunday, February 21, 2010 10:36:17 AM

The idea seems excellent to me! I shall start trying the script immediately.

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies