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.
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.
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)