Skip navigation.

Programmer's notes

Opera::User JS

, , ,

One of the greatest features of Opera is User JS. User JavaScript allows you to specify local JavaScript files for Opera to include on every page that you visit.

Some web-pages do not provide a functionality that is requested by a user. For example the "vkontakte" social network always warns a user about "possible malicious site" every time a user clicks an external server's link. 4 lines of code solved the problem.

// ==UserScript==
// @include http://vkontakte.ru/away.php*
// @include http://www.vkontakte.ru/away.php*
// ==/UserScript==

var link = document.links[0];
document.body.id = "body";
document.getElementById("body").innerHTML = "";

window.location= link;


The code is pretty self-explanatory, but in case if you're not familiar with JavaScript and Document Object Model, let me explain:

First, we include the urls that should be monitored by this script. This is a part of Opera User JS technique.
Then, we declare a link variable and store the first available link on the page to it. We know, that there is only two links on the page, and the first is the required one:



Then we search for a body tag and remove it's source HTML. So, we won't see the warning message.
And at last, the script automatically redirects us to the desired link.

That's pretty easy, isn't it? You can learn more about Opera's User JS here

Beginners guide to creating a GNOME applet with Python (Part I)Byte-compiled ChangeLog

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

Download Opera, the fastest and most secure browser
November 2009
M T W T F S S
October 2009December 2009
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30