Skip navigation.

web:config

tips and tricks for the interwebs

STICKY POST

typical disclaimer

So, you're interested in javascript and other related matters? Then this blog might interest you.
However, please do note that this is a personal blog, maintained solely by me and not endorsed by any other 3rd party, included any employer of mine. So if I feel like bashing some multibillion dollar company, or a community of fanboys, that's my personal rant alone. The same applies to everything I write on this website, namely forums.

All user scripts I offer are obviously free of charge and devoid of any malicious code that might harm the user in anyway, like stealing data. I WILL NOT in any case build a script that harms users. I have the utmost respect for whom uses my scripts, and I hope they will improve whatever you feel like needs to be improved.
However, I will not be held liable for any harm or problems the script might cause to you, probably due to bugs or non foreseen situations. So use the scripts at your own will and risk. They still have my personal guarantee of quality.

So, to finish, I hope you'll find useful resources here, and learn a few things. I hope you have as much fun using my stuff as I had building them. Have fun!

backup your profile

Hi !
Backing up your profile is recommended when you're upgrading Opera or trying snapshots. However, the process of opening the file manager, selecting the profile folder contents except the cache folders and other superfluous content is tedious and boring.
It's much more easy to just open a terminal and type
$ backup-opera-profile
and for that I did the following bash script, linux only currently.

backup-opera-profile

It has a few usage options
~$ backup-opera-profile -h
Usage: backup-opera-profile [options] [archive name]

  -h, --help     Shows this help

  [archive name] Archive name (tar gzipped) where the profile content
                 will be saved. Value is optional. If not supplied a
                 name will be generated using the current date for
                 uniqueness. If -r is specified, the profile is restored
                 from the archive, and the archive name is mandatory.
                 The later action cannot be undone

  -d, --dry      dry mode. Does not create/change any files,
                 just displays what would happen

  -r, --restore  Restores profile from 'archive name'.
                 'archive name' argument becomes mandatory

  -p, --prefix   Parameter must be followed by profile folder name.
                 If ommited '.opera' is used. If the prefix is not
                 an absolute path, then it'll beresolved against the
                 user's home folder, not the current working folder
Example:
  $ backup-opera-profile
or
  $ backup-opera-profile -p .opera-weekly -r backup-20080524.tgz

So, now you don't have an excuse to always have the latest snapshot installed p:

a better quicktime

, , ,

Hi !
Linux users have traditionally been plagued from deliberate lack of support from many big companies for Linux.
In the current particular case, Apple has never done QuickTime for Linux, and I'm happy they never did. People argue about QuickTime being one of the worst softwares done by Apple. But back on the matter, not having the QuickTime plugin means that webpages that actually check for it will not work. Fortunately, this situation is not THAT common.
However, it exists, for instance, Apple's movie trailers website.
So, what should Linux users do (and Windows users which do not have QuickTime installed) ?

I made a really simple script, which detects if the QuickTime plugin is installed, and if it's not, it just creates an entry on navigator.plugins with a fake QuickTime, and it works great. Note however, that if the webpage tries to manipulate the plugin with scripting, it will most likely fail, because the plugin used by the browser might not support QuickTime's scripting API..

Download here:
xerath-add-quicktime-plugin.js
You can test it on the link above.

Have fun!

EDIT: clarification - you need to have another plugin that can handle QuickTime, like the VLC plugin.

gallery crawler

, , ,

This time I have a really simple script, which I did long time ago. But, it's very useful nonetheless.
How many times did you go image galleries, and had to flip through links, ads and poor page design to browse the gallery?
Unfortunately that's quite common. But, it's also quite common for pictures to be numbered sequentially.
For these cases I have the following solution:


The script adds that small menu, only visible if hovered (so it won't cover the image), and the keyboard also works. n goes to the next, p to the previous.
So, if you like the idea, download the script from
xerath-gallery-next.js

Have fun ! :smile:

EDIT (03-June-2009): I did a small update because images were dissapearing sometimes in imageshack. You may re-fetch the script

for heavy duty posters

, , , ...

I present you with a new script to enhance user experience on my.opera, dubbed Scribit.

The script provides the user the hability to edit all his/her forum posts, blog posts and comments, dev.opera comments and widget discussion's page comments without the need of opening a new webpage with the edit form. The script will create a inline editor, that will replace the original post, or comment, so the user can edit it inplace, therefore making editions much more pleasant and quick. The script also displays a inline toolbar with all the available formatting commands used to produce bbcode. The toolbar is not only displayed in the inline editor, but also in the already existing reply boxes in the forums, blogs and at dev.opera.

This script initially only worked for forum posts and was very simple. I coded version 2.0, to submit to the User Javascript contest but by influence of the others the script never got to the juri's inbox. Oh well...

Screenshot with default setup (standard skin)

Screenshot of Quick Edit link

Screenshot of post quick editing (Oxygen skin)

Instructions
The following keyboard shortcuts are supported in the inline editor, producing bbcode formating. Press Ctrl plus any of the following keys:
  • b - bold
  • i - italic
  • u - underline
  • s - strikethrough
  • p - preformatted code
  • t - insert unordered list
  • l - align text to the left
  • g - center text
  • r - align text to the right
  • j - justify text
  • m - insert image
  • h - create hyperlink
  • e - insert email link
  • f - attach file
  • q - format text as quote
  • w - whisper text
  • ENTER - submit post
Later on, I'll make these easier customizable.

The script's configuration has sensible defaults. The entire UI is drawn using the current Opera skin, therefore providing an extra integration with the browser. Note however, that some skin bugs might be releaved. This script was succcessfully tested with Opera's default skin, and some other popular skins.
You can tweak the editor's behavior, although you need to edit the script itself.

This script does a daily new version check, warning the user of the new script version. You can disable this feature though. Check the configuration kCheckForNewVersion.

This entire script was done by me from scratch. The version check code was imported from the myopera-enhancements script, also made by me, and Robin Zalek. I recomend you to check it out. :cool:
http://my.opera.com/xErath/blog/2009/02/10/my-opera-community-enhancements

Credit also for AyushJ's quick-reply script for some inspiration. :wizard:
http://my.opera.com/community/forums/topic.dml?id=185091

Many thanks to Lars Kleinschmidt as well for testing and feedback. :wink:

However, the script has much to catch up. The roadmap is:
  • finishing html editing support :yikes:
  • supporting html to bbcode convertion and back on the fly
  • adding a 'remove formatting button', trivial for html, hard for bbcode :knight:
  • removing all prompt boxes and replacing them with proper floating
  • menus providing the user input suggestions, like listing his/her files when the attach button is pressed.
  • replacing the default new blog post, new form thread, and new dev opera article
  • making a lovely UI to edit configurations

Etimology: Scribit derives from scribe :spock:

Download the script from:
xerath-myopera-scribit.js
Future versions will be announced here, and the script will notify the user of the new version.

For the geeks
Script documentation is available at, generated using JSDoc:
scribit-documentation.zip

All text strings stored by this script are properly grouped to ease the script's localization. Currently, the suported languages are english and portuguese. Other users are encouraged to contribute. The language is autodetected and will match your UI language, but this can be overriden by setting the kPreferedLanguage configuration variable. If the UI language is not supported, english will be used.

Translations code chunk:
var translations = {
    en:{//plain english 
        L_SUBMIT: 'Submit',
        L_CANCEL: 'Cancel',
        L_QUICK_EDIT: 'Quick edit',
        L_QUICK_EDIT_LINK_TOOLTIP: 'Quick edit this post using inline editor',
        L_ERROR_ON_LOAD: 'Error loading post from server',
        L_LOADING_DATA_STATUS_MSG: 'Loading data from server...',
        L_POST_NOT_CHANGED_NOTIF: 'Post not changed (to quit press Cancel)',
        L_SUBMITTING: 'Submitting...',
        L_ERROR: a'Error',
        ...

Have fun! :cheers:

My Opera Community Enhancements

, ,

For those of you who still do not know "My Opera Community Enhancements" user script, I seriously recommend you give it a read. The script improves the user's experience here at my.opera. For a full feature list, just read the following documentation:
http://files.myopera.com/xErath/mopen/myopera-enhancements.html

The script was done mostly by me and BtEO, although BtEO will no longer participate in the script's development and maintenance.
Forum discussion at:
http://my.opera.com/community/forums/topic.dml?id=172834

Script contributions and bug reports are more than welcome.
Have fun, as always :smile:

Edit:
Whoops Homer: Doh! ! Forgot to post links...
Script: myopera-community-enhancements.js
External prefs file: myopera-community-enhancements-prefs.js

the interwebs accesses your system !

, ,

Ever wonder how you could have system access, file IO or other capabilities from a html page hosted elsewhere?
Well, in Opera and Mozilla, you can do it with Java, like...
<script type="text/javascript">
java.lang.Runtime.getRuntime().exec("command arg1 arg2");
</script>
and that command should execute just fine. But first you need to give Java permissions to execute that, so go to Opera's installation folder and locate the classes\opera.policy file.
Open it and add the following rule:
grant codeBase "http://mytrustedserver/-" {
    permission java.security.AllPermission;
};
where mytrustedserver is the name of your server. "file://-" is also allowed.
That way java will have permission to do system call, File IO, etc. However, you're enabling permissions with a sledge hammer this way, but it's just for the sake of testing. Still, you should have a good read of java security policies, if you want to make this widely available.
http://java.sun.com/j2se/1.3/docs/guide/security/PolicyFiles.html

You have the entire java API available.
This should work
var file = navigator.platform.indexOf("Win")>=0 ? "c:\\file.html" : "~/file.html";
var output = new java.io.PrintStream(new java.io.FileOutputStream(new java.io.File(file)));
output.print("<h1>hello world</h1>");
output.close();
java.lang.Runtime.getRuntime().exec("opera "+file);

If you're having problems, analyse what is displayed on the Java console (Tools>Advanced>Java console).

Beware, others can eavesdrop scripts on your browser, but if you're coding for yourself, then you're fairly safe.
Note: don't try to fool users into changing their policy file for bad reasons. It's not worth it.

Happy development :smile:

http phones file

, , , ...

Hi to everyone!

As some of you might have experienced, Opera blocks access from http: pages to file: or http: in the internet to http: in the intranet.
This however, causes an unfortunate situation where you can't use Opera, for instance, at work if you have intranet web apps that point to network shares with content.

However, this because just an annoyance which is workaroundable.
The trick is simple: set the file: protocol to be handled by an external application, and you should be done. That external application can be Opera again, and in this case, it'll open the network path in a new tab, just like if you clicked an http link normally.
You can also use either of the following depending on your OS/desktop environment:
  • "explorer" on windows - beware, html files will be opened in IE :yuck:
  • "kfmclient" on linux with KDE desktop
  • "gnome-open" on linux with Gnome desktop
  • "open" on Mac OSX

But, unfortunately, we're not over. Opera has two bugs which make this solution not that straightforward (yes both are reported).

First, some UNC paths are misresolved, for instance:
<a href="\\server\share">
<a href="file:\\server\share">
Although these paths are not valid URIs, some tools generate then, as I've seen.
For instance, if you add a url like \\server\share in MediaWiki, it'll convert it to file:\\server\share

Second, despite being set to open with an external application, Opera still blocks http: to file:.

Solution:
  • to overcome the misresolved links,obviously we'll use an user script
  • to overcome the http: to file: block you need to rename file: to something else and tell Opera to open it, so we'll use an user script for this as well.
So, install the following user script, which fixes the links and converts file: to file-opera:.
fix-file-protocol.js
Second, choose one of the following scripts according to your operating system
  • Windows, place the file in the Opera installation directory
  • Linux, place it where ever you like
  • Mac OSX, place it where ever you like

Third, go to Tools>Preferences>Advanced>Programs and add a new protocol "file-opera" to be handled by the script you just saved. These scripts open the url in Opera. If you want them to open another program then you're free to edit them yourselves.

And that should do it.

Have fun :smile:

We only know what indexOf is

, , , ...

It seems like yahoo.com somehow is blocking Peregrine


I'll leave you with a quote and let you draw your own conclusions.
http://my.opera.com/Andrew%20Gregory/blog/2008/05/11/opera-10-is-too-old

Originally posted by Andrew Gregory:

If you're one of those people irritated at how poorly Opera appears to handle web site scripting - this is one of the bigger reasons. It's straight-out careless programming without thought.

happy birthday!

, ,

It seems today is my birthday! :hat:
People all over the world are celebrating! :wink:

now if I could just skip work for today... :whistle:
Download Opera, the fastest and most secure browser