~ Tutti all'opera! ~ Essays ~
|
|
|
Fravia's special pages |
Personalising Opera using javascript
by ~Roman
this was written 27 March 2005
There are several good pages on searchlores
(e.g. http://www.searchlores.org/ritz__3.htm)
that describe using bookmarklets to
add functionality to browsers. However, simply using bookmarks is not, I
believe, using this technique to its fullest potential.
Opera has an excellent feature which enables you to add buttons to the toolbars
using a special syntax:
This special type of hyperlink is recognized by Opera:
Clickable and draggable link
Code for the above link looks like this:
<a href="opera:/button/<action text>"
title="<default button title>">
Clickable and draggable link</a>
Replace <action text> with the button action.
see "http://nontroppo.org/wiki/CustomButtons" for a
lot of custom buttons using
opera's built in functionality (try dragging these buttons into your toolbar,
cool eh?).
How do the bookmarklets fit into this ?
Try using
"opera:/button/Go to page,"javascript: <insert javascript>;"
This allows you to create buttons in opera that will do anything a bookmarklet
can do. You may be thinking "how does this improve over using bookmarklets?",
well this syntax that opera recognises is not limited to buttons, but can also
be used in mouse gestures and keyboard shortcuts.
This opens up all sorts of new functionality... try going to
Tools->preferences, then finding your way to the mouse shortcuts (you may want to
duplicate your current mouse gestures, so you can modify them without losing
them), finding the GestureDown field, double clicking on the action and
deleting the text that is there ("Open link in new page | New page"). Replace
it with the following:
put everything on a single line
Go to page,"javascript:expr=prompt('Length in kilometers:','');
if(expr){if(isNaN(parseFloat(expr))){alert(expr+' is not a number')}
else
{void(prompt('Length in miles is',Math.round(expr*6214)/10000))}}
else
{void('')}"
I took this piece of javascript from "MarcFou" in the customizing Opera
"bookmarklet" thread in my.opera.com forums
Try it now. After this is complete, try holding the left mouse button down and
dragging the mouse downwards. It should prompt you for a length in kilometers,
which it will then convert to miles.
This is obviously not all you can do with it - anything you can do with
javascript can be done with this. Look at any bookmarklet page for ideas.
Also, don't forget that anything that can be done with mouse gestures can also
be done with keyboard shortcuts and buttons. All of this could greatly increase
the efficiency of using a browser.
Wanna learn more ? "http://nontroppo.org/wiki/AllActions" for
Opera's button
commands.
also "http://my.opera.com/community/" and look for "customizing Opera" forum.
-------------------
Continuing, not only can arbitrary javascript be executed, but also
arbitrary executables . For example, you are in opera and want to see what
the current page would look like in IE?
opera:/button/Execute program,"iexplore","%u",,"Ie"
That button will do the trick. But now you are not just limited to javascript.
Think of the possibilities :-)
Experiment a little.
--------------------
Adding google search to the side panel in opera.
create a bookmark called: http://www.google.com/ie
(this is the "no adds" version of google) and tick the "Show In Panel" box.
You can then do google searches in the side panel, and keep all your results
visible while you browse the pages. Remember, this is not only for google! And
remember to select "view->small screen" to make it look right.
p.s. I'm doing this in opera 8 beta 3, so there are no promises about any of
this working in earlier versions, but chances are it will.
Finally, since we are on a "Opera-related" page, a famous svdism (Svd's wisdom):
"hit ctrl-B in opera. Then LEARN it by
mind!"
you'll thank me more than once for this advice...
Back to tutti all'opera!
(c) 1952-2032: [fravia+], all rights
reserved