Skip navigation.

web:config

tips and tricks for the interwebs

Posts tagged with "user javascript"

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

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:

Meet meenoo and drag

, , ,

I've previously posted at the forum two scripts to resize textareas.
Now I'll release them here.

Meet the two siblings: power-drag and power-meeno. They complement each other, one being more complete, the other being more broadly usable. Both these scripts started out from the simple desire of resizing textareas easily, alla CSS3 UI. If Safari can do it, then why should not Opera, with some bells and whistles?



Power-meenoo adds a small menu which can be toggled by pressing ALT and hovering a textarea. The menu has many options, and the script is localizable, currently translated in english, portuguese (duh p:) and polish (credits to Wasacz). The options are self explainatory, so you can bore yourselves trying them.

Power-drag is simply cool. Probably I should call it "awesome script"? Pressing your shift key then hover textareas, select boxes, iframes, objects, images or input fields to simply resize them by dragging its lower right corner. Simple, clean and efficient. Double click to restore the original dimensions. You can enable the dragging corner always, or use another modifier key. The script requires shift by default because makes the script less intrusive, and does not cover small elements in the page, while having a smaller performance impact.

One script DOES NOT require the other to function properly. They're independent.

Now, you might recall these scripts from the forum. Power-meenoo now requires alt because ctrl is usualy associated with clipboard shortcuts, shift with selections, so that leaves us with alt which is usually associated with menus, so it fits well.
The old scripts you had resize-textarea-util.js and textarea-drag-resizer.js are therefore deprecated. Please delete them if you want to download one of these scripts.

Get them here.
power-drag
power-meenoo

As always, updates will be annouced in the blog post, and the links always point to the most recently updated files..

Plugsome Toolbar

, , , ...

I present you, right from xErath labs, beign these a two year old laptop (which works just fine), the "Plugsome Toolbar" user javascript. It's fairly simple to use, and very useful.
In the screenshot that follows you can have an idea of what it does::cool:



This script is an utility that add a small toolbar to plugins in webpages.:raider:
The toolbar by default has 3 buttons:
  • the 1st button is a Reload button which reload the plugin content
  • the 2nd button is a link to the external file that the plugin loaded. Somefiles might get special treatment, like in youtube. Instead of linking to youtube's media player swf, the script links to the video file. Click this link to save the file.
  • the 3rd button is a X which if clicked closes the toolbar, and if double-clicked removes the toolbar and plugin from the page. The space that the plugin occupied is preserved though.
The toolbar is dimmed by default, and it'll highlight when you hover it.
If the toolbar is attached to a Flash file, then you get two extra buttons: a play and a pause button. Note however, that play and pause might not pause/resume plyback in all flash files. This is due to the file's internal structure, and the way content is layed out in the Flash's timeline.

Download link:
xerath-plugsome-toolbar.js
Further updates will be annouced, the link above will point always to the latest version.

Technical details
The script applies different treatment to differents objects in different websites, when returning the link of the file feed to the plugin.
The script already support youtube.
To add your custom behavior for a specific website, the user script exports a small interface.

All functions and variables are grouped in the opera.PlugsomeToolbar object.
The object has the following properties:
  • version - script version
  • URLHandlers - an object with host names and custom functions to apply to a html OBJECT or EMBED to have the link that is available in the toolbar.
  • URLHandlerFallback - a fallback function that should be called when custom functions in URLHandlers require to work asynchronously, but fail to retrieve the file url
  • AllToolbars - an array with all the instantiated toolbars in the current page.
The object looks like this:
a.PlugsomeToolbar = {
    version: '1.0',
    URLHandlers: {'a':...}
    URLHandlerFallback: function(){...},
    AllToolbars: [...]
};

To code your own website rule, do something like this:
opera.PlugsomeToolbar.URLHandlers['.youtube.']=function(object, link){
    var fv = object.getAttribute('flashvars');
    if( fv ){
        /* ... */
        link.href = 'http://www.youtube.com/.....';
        return true;
    };
};
You can, and should place it in another file, because that way you can easily upgrade Plugsome Toolbar without loosing functionality.
The functions in URLHandlers receive 2 arguments, the plugin and the toolbar link to fill in the href. Each function returns true or false, respectively, in case of success or fail. The script, for each plugin, loops through all rules and aborts when one returns true, meaning that the link is known.



cow You might find the name "Plugsome Toolbar" familiar. The original one was invented to feed hype for a specific piece of software, when others did the same thing that the former advertised.
But we're not here to talk about Firefox,... whoops, I said it... :whistle:

EDIT (2008-June-11)
New update, version 1.0.2.

Changelog:
  • Option to show toolbar when plugins are disabled
  • Added Quicktime and windows media player controls toolbar
Note: the quicktime controls may not work in. It seems quicktime scripting is broken in Opera. But the work is done, until Opera get fixed.

Developer tools unleashed

, ,

Allas ! The wish of many developers and Opera fans was partially fulfilled ! Real developer tools officially supported in Opera :yes:
See some screenies
I personally have my own tools, but Opera's ones seem much more polished, and since they're in javascript, they're fully editable. :yes:

But, being me the techie person I am, aka geek, and knowning that the tools announced at dev.opera are scripts, I opened my menu.ini, and saw the following
[Advanced Tools Menu]
Item, 69887            = Manage cookies
Item, 69888        = Manage wand
Item, 920136405    = Content block details, 1
--------------------1
Item, 50838            = Go to page, "opera:plugins",,,"Blank"
Item, 50835            = Go to page, "opera:cache",,,"Blank"
--------------------3
Item, 54122            = Show Java console
Item, 67476            = Show Message console
Item, "Developer Console"="Go to page, "javascript:(function(){var ele=document.documentElement.appendChild(document.createElement('script'));ele.src='http://devfiles.myopera.com/tools/developer/8679/devConsole.js';ele.parentNode.removeChild(ele);opera.tools.console.open();})();", , , " ""
--------------------4
Item, 51212            = Refresh display


Neat, uh ? :right: hum, maybe not.
What happens if you are offline, or have javascript off ?
Besides, the script is 170kb, which takes time to download, or check if it's not modified, therefore the menu entry does not respond instantelly, which is a usability problem.

The solution is simple. Download the file http://devfiles.myopera.com/tools/developer/8679/devConsole.js to your user js folder, and add this as a bookmarklet, or replace the Developer Console command with
javascript:(function(o){if(o&&o.tools&&o.tools.console&&o.tools.console.open)o.tools.console.open();})(window.opera);
and you're done.

Don't forget to periodically check for the script version.

Happy development ! :yes: :hat:

The world through a Google

, , , ...

Note: I'm not in any way affiliated to Opera Software or Google Inc. The opinions expressed here are my own only :spock: .

After having gained some notoriety, both in this community, and outside, I feel like I should announce probably the most useful user script I've made. Unlike what you may think it's not an enhancement, but a unified patch from some of the most awful discrimination on the web: Google services.
Unlike what many not-so-techie-people think, Google is not superman.
quiris asked me:

Originally posted by quiris:

Many Fx zealots complains in comments that it's Opera fault, not Google's. So xErath, could you explain the all patched problems in Google services are necessary because of bugs in Opera or rather because of Firefox/IE-centric code?

Here's the answer for you all. No software is flawless, all have problems, quirks and bugs to workaround. I not saying Opera is bug ridden. Much on the contrary, IE has some of the worst DOM support ever, and Mozilla too has it's quirks and mis-behaviours. As consequence, developers make their applications against browser behaviours instead of the specification. This eventually breaks Opera which gets some workaround for one of those browsers bugs, which misbehaves, or too hits a bug which needs a workaround. So it's a bit of all issues, browser specific code, Opera quirk, or bad object detection.
For many of those Google services to work, the compatibility would be ensured by fixing problems on both sides. Guess what? Opera is doing its job, but Google isn't because they probably feel like 1% of the market and the Wii users aren't worth it. Google definitely doesn't like you.
So I avenged many Opera users, and did a patch for many Google services to work in Opera, mainly because I use Google too a lot.

Where's a description of what the script does:
  • Google spreadsheets - nothing much to fix. Simply reverses the mousewheel, so when you roll it down, the pages goes down. It's a known quirk. Then it warns the user to Mask as IE, if it's not, which is the only way for the site to work. If the browser is Masked as IE, the page tries to use IE's css filters to display transparent PNGs. So there's a workaround for this one too.
  • Google Calender - simply makes the "browser not compatible" notification to go way, and for the create event date popups to work.
  • Google Picassa Web - simply overrides bad browser sniffing. Now the website works just fine, including the slideshow (shame on them :irked:)
  • Google Docs - this is more complicated. The writely team, which built the editor you see thrived to have their application working in the 4 major browsers: IE, Moz, Opera and Saf/Konq. The word Safari is scattered all over the code, to workaround it's problems (Safari's DOM was weak at that time). But then Google ate writely, and all efforts for interoperability were squashed. The patches fixes many issues related to bad object detection, and overrides a few quirks in Opera.


I hope you put this script to good use, and have more fun using it, than I have writing it :right: .

Here you go:
fix-google-services.js

Next stop for me might be Google Page Creator, because it seems to share components with the new Google Groups beta. Refer to this post for updates.

Edit: BtEO worded wonderfully mine and other Opera's power users sentiments.

Edit 2 (21-april-2007): I have no intentions of bad mouthing Writely's developers, which previously showed interest for Opera. It seems after all, that one of the major blockers for Safari, are bugs related to selections and designMode, although the current Safari 3 nightlies seem promising. In the mean time, there was a little update to google docs javascript code a bit more Opera friendly. Thanks to them.
I've done some heavy work with google pages, but it's a nut terribly hard to crack. Google pages developers really only care for 2 browsers, which flooded the code with a enormous amount of browser quirks usage, or using Mozilla or IE's bugs as features.
I'm aware that spreadsheets isn't working fine. IT seems a bit unstable: most of the time it works, but them all the sudden is seems broken. I have no intention of debugging more. If you want a real spreadsheets application try EditGrid.
Currently I have little time to improve the script, so contributions are wellcome.

Edit 3 (11-april-2009): the script was updated, which was simply removing deprecated code. Currently, docs, spreadsheets and the calendar work very well. kudos to Google. picassa is the odd one left.

Note: script updated 11-April-2009
Download Opera, the fastest and most secure browser