Skip navigation.

halO

ecmascript, programming, hackery, rants, insight, science and of course Opera

Posts tagged with "userjs"

Opera Adblock

, ,

I wrote a small UserJS which is blocking all external javascripts. It worked very nicely and sped up ad intensive pages something fierce.

However, the script was blocking all scripts which did not originate from the page you were visiting. This mean that inline youtube videos, google maps and such nice addons didn't work. It didn't take long until I didn't use the script myself. Again I had to live with slow pages...

So I got tired of it again and modified the script. This time, I use a blacklist. Of course this means I have to update the blacklist, but at least this time I won't get broken sites unless I tell the script to do so.

The blacklist is currently very short and I've only used it for a few hours, but it seems to be working nicely so I'm releaseing it. Install the script, read the previous post if you don't know how, and if you'd like to help out you could gather more links to put in the blacklist.

Download

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.

UserJS for Google Video

, , ,

I like watching documentaries on Google Video, but with Googles aquisition of YouTube they now also include search results from YouTube when searching from Google Video.

I didn't like this very much, so instead of adding site:video.google.com to every query manually, I wrote a UserJS that adds a default site search button. Enjoy.

How to enable UserJS

  1. Put the user javascript file in a folder along with all other scripts for the site you wish to alter. My personal preference is to name the folders by domain, so for Google Video the folder name would be "video.google.com". I also recommend placing all such folders inside a "userjs" folder.
  2. Go to the site in question. In this instance that would be http://video.google.com/.
  3. Right-click on an empty space to bring up the page context menu.
  4. Select "Edit site preferences...".
  5. Go to the "Scripting" tab and click "Choose" besides the text box at the bottom.
  6. Select the folder where you placed the sitesearch.js file you downloaded from this post. You will probably need to restart Opera before the script becomes active.
  7. You should now see a button titled "Search Google Video" next to the search box at Google Video, just before the regular "Search" that was already there and still functions as normal.