User JavaScript: Opera's answer to GreaseMonkey

Index » Feedback

  • 1
 
woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Opera 諸君, rejoice. I've been able to convert one of my GreaseMonkey scripts to User JavaScript, Opera's self-styled scripting feature, akin to GreaseMonkey and in theory capable of directly handling GreaseMonkey. In practice, I had to tweak the script to make it run correctly, forcing me to change the file extension, which is no longer .user.js but simply .js, so that now we're talking about different files altogether.

The script in question is Kanji.Koohii: Add upto flashcard number, which was described in the Add Flashcards thread. Click the first link to access the script.

To install, first check your Download folder, which is specified under Tools->Preferences in the Download tab. Change it to the folder where you'd like to store your user scripts under (e.g. create a UserJS folder in My Documents first and point to this folder). Select the Advanced tab now, click the Javascript Options button, and under User JavaScript-map fill in the same directory. Push Ok. Now right-click on the above link and select the Save to download folder option.

More scripts to come. For those of you who have never heard of Opera, it takes about 5 minutes to download and install, so try it. It's a free tabbed browser with lots of features (where did we hear that before?).

Last edited by woelpad (2007 January 31, 2:30 am)

stefanot
New member
From: Italy
Registered: 2006-10-25
Posts: 2

Hi, I've been using one of your greasymonkey scripts (ADOPTING A STORY) as is on opera 9.0x in the last months, and it works without problem. Very useful too !

I did not notice any problem with the filename extension, but to tell the truth I tried it only with Linux and MacOsX versions of Opera. (Could be a problem with extension under windows?)

woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

stefanot wrote:

Hi, I've been using one of your greasymonkey scripts (ADOPTING A STORY) as is on opera 9.0x in the last months, and it works without problem. Very useful too !

Must be an older version of the script. The current version uses the unsafeWindow variable, which Opera doesn't recognize. It is in some cases possible to write the script in such a way that browsers like Opera, which support an earlier version of GreaseMonkey or in any case only a part of the functionality of the current one, can interpret directly. But commonality is not my goal, and Opera has its own sophistications to deal with the same problems, which I'll be exploring next. Very educational if you take an interest in programming.

stefanot wrote:

I did not notice any problem with the filename extension, but to tell the truth I tried it only with Linux and MacOsX versions of Opera. (Could be a problem with extension under windows?)

No, my solution was to use a variable that Opera doesn't expose to GreaseMonkey scripts (window.opera to be precise). Opera makes a distinction between a GreaseMonkey script and a proper User JavaScript script purely on file extension (.user.js for GM, .js for UserJS) and sets up a slightly different environment to handle each. Nothing to do with the OS.

It does imply that I'm now creating two different scripts for each solution, which increases the maintenance task (although not overly much, once the differences are properly understood). I'm loathe to add more variations for other browsers. My hope is that if a feature is that useful, it will eventually find its way into the original code, and I can simply dump all my scripts.

Advertising (register and sign in to hide this)
JapanesePod101
Sponsor
 
woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425
woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

I've found a more elegant way to download these scripts. Rephrased the first message accordingly.

Bug fix for Kanji.Koohii: Copy Story. Frame links were not properly recognized.

Adapted Kanji.Koohii: Story with Line Breaks and Kanji.Koohii: Clear and restore story (a little gem, but few people are aware of it).

redtricycle
New member
From: San Francisco CA USA
Registered: 2005-11-21
Posts: 6

I'm ecstatic that there are other people who use Opera.  Thank you woelpad for these great adaptions!

woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Updated the Kanji.Koohii: Copy Story script to enable reversing bold and italics, as described here. The "Create Story Links" script will take a bit longer, because of incompatibilities with the "Line Breaks" script. The altered Kanji.Koohii: Tag Title is simply the Greasemonkey script itself (more on that in the Suggestion: Page Title thread).

Last edited by woelpad (2007 February 23, 3:43 am)

woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Finally succeeded in making Kanji.Koohii: Story with Line Breaks compatible with Kanji.Koohii: Create Story Links. You will need to download both, and, if you haven't done so already, upgrade to the latest Kanji.Koohii: Copy Story for compatibility.

Reply #9 - 2007 March 14, 5:34 am
ファブリス
Administrator
From: Belgium
Registered: 2006-06-14
Posts: 3704
Website

Btw just found out about this, you might find very helpful if you like Opera:
Opera developer tools

Reply #10 - 2007 May 24, 4:07 am
woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Since nobody asks, I'll answer myself the obvious question.

Why are not all greasemonkey scripts available in Opera?

The main reason is that User Javascript does not have native methods for persisting (i.e. storing/retrieving) data (such as the font you want or the keywords you chose) on your machine. I've seen a method for persisting data through the use of cookies, but cookies expire, they can be erased from the system at the click of a button, etc. I'd rather wait for a native implementation of GM_setValue/GM_getValue. If you hear there is one, let me know.

Reply #11 - 2007 June 14, 4:51 pm
woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Finally updated those broken scripts: Line Breaks, Copy Story and Links. The fact that I don't have Opera installed at my office is an impediment. Downloaded and tested on the new Opera version, 9.21.

Reply #12 - 2007 July 18, 9:09 am
narafan
Member
Registered: 2007-05-30
Posts: 66

THanks a bunch woelpad! big_smile

woelpad
Member
From: Chiba
Registered: 2006-11-07
Posts: 425

Another update cycle. Updates for Story with Line Breaks, Add/remove number of cards, Insert Story Links and Pictures and Copy Story. They now offer the same functionality as their GM counterparts, except for a small inconvenience in Line Breaks, which still reloads the page after showing the size check alert.

For Add/remove cards, if the add button doesn't work well, check if you still have a copy of the previous and slightly different named script, Add upto frame number (the file name is similar to the title); if so, delete that old script, since it interferes with the current one. I think the other file names remained the same, but in case of difficulties, check your script folder to be sure. Installation instructions in the first message of this thread.

Last edited by woelpad (2008 April 01, 8:41 pm)

  • 1