Skip navigation.

halO

ecmascript, programming, hackery, rants, insight, 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 autosaveSearch

Comments

decimal 29. July 2008, 23:34

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:

apa240 30. July 2008, 01:11

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 1. August 2008, 19:47

stroh writes:

I think I love you.

GregLand 15. September 2008, 12:08

Perfect !!!!
Nice Script...

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