[UserJS] OSpell - A Better Opera Spell Checker

Forums » General Opera topics » User JavaScript

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

22. March 2007, 20:48:26

Opera Software

d.i.z.

bug hunter

Posts: 3029

[UserJS] OSpell - A Better Opera Spell Checker

This might get a little boring but there is Yet Another Spell Checking Script in town.

After Orangoo Spell Check 1 (Sombria), 2 (me) and 3 (amix), here is another version that tries to mix all the pros of older versions. 95% of coding was done by Sombria, the other 5% by me.

Some of the most important features are:
  • Can use both Orangoo and Gmail spell checking engine (the latter requires to be logged in with 'remember me' option checked).
  • Is as fast as amix version as all code is contained in script (and much smaller wink).
  • Support for keyboard shortcuts, RTL mode, input fields...


Here is the main script:
ospell.js
and external preferences file:
a-ospell_prefs.js
Use external preferences if you want to customize settings and be sure that they will retain when updating main script.

Enjoy.

Script can use one of the three spell checking engines (ENGINE setting in preferences).
  • ENGINE: 0; is GMail. To use it you have to login into GMail with "remember me" checkbox enabled. After you do that, you will be able to use GMail engine for spellchecking in OSpell.
  • ENGINE: 1; is Orangoo. This is a spellchecking service created by amix that works as a standalone service but we kinda hacked into it (don't worry, amix knows smile )
  • * ENGINE: 2; is offered by fearphage. This server was kindly set up by my.opera member and runs spellchecking software created by amix (again).

* This one is enabled by default.
[/quote]

22. March 2007, 21:02:52

idleskitter

relax max

Banned user

Thank you d.i.z. cheers

22. March 2007, 21:30:35

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

Thanks d.i.z. up

Checking it out now smile

One thought sherlock would it be possible to use the installed Aspell dictionary for spell checking?
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

22. March 2007, 21:31:48

ThalSwe

Posts: 15

Thanks d.i.z.
There is a lot of work being done on these spellcheckers these days but more "competition", more work and new versions of them just benefits us users. Keep at it!

22. March 2007, 21:42:23

Opera Software

d.i.z.

bug hunter

Posts: 3029

Originally posted by ThalSwe:

One thought would it be possible to use the installed Aspell dictionary for spell checking?


No, user scripts can not do such magic directly.
But you can instead run local Nox Spell server which requires quite some work to set up.

Originally posted by ThalSwe:

There is a lot of work being done on these spellcheckers these days but more "competition", more work and new versions of them just benefits us users.


The problem being that version 1 and 2 are discontinued and amix declared that he is not going to maintain his version. So that leaves us with just this one. wink

22. March 2007, 21:46:45

ThalSwe

Posts: 15

Originally posted by d.i.z.:

The problem being that version 1 and 2 are discontinued and amix declared that he is not going to maintain his version. So that leaves us with just this one. wink



But one version lead to another and so forth so it still was benifital in that kind of way for a moment at least wink Nobody is saying this wont get compeditors in the future either.

This is just a minor detail and really...this is good stuff and I like it.
So again, thanks.

22. March 2007, 21:49:44

YtseJam

Posts: 4660

Looks like Google is used by default. Anyway, the list of languages is aligned to the right here and there is some problem with the "(" sign (damn I forgot the word!) And, Hebrew doesn't show up in the list?
Hebrew Forums Moderator | Hebrew Group

22. March 2007, 22:09:27

Opera Software

d.i.z.

bug hunter

Posts: 3029

Originally posted by YtseJam:

the list of languages is aligned to the right here


Never ending battle with page styles affecting our elements. Will have to use custom elements.

Originally posted by YtseJam:

there is some problem with the "(" sign


When checking english text? Example please.

Originally posted by YtseJam:

And, Hebrew doesn't show up in the list?


Will be added to the list of supported languages for GMail. It's already enabled for Orangoo so you might try setting engine to 1.

22. March 2007, 22:16:57

YtseJam

Posts: 4660

It happens when in an RTL page, or at least when the text field is.
See screen shot:

I think it'd be best to keep the dropdown always as LTR.
Hebrew Forums Moderator | Hebrew Group

22. March 2007, 22:56:34

DynaBMan

Posts: 978

I am getting an "invalid response from server" error.
LJ
My best friend is my wife!!

Political Realities

22. March 2007, 23:00:39

Opera Software

d.i.z.

bug hunter

Posts: 3029

Originally posted by DynaBMan:

I am getting an "invalid response from server" error.


Log in to GMail first or change ENGINE in script.

22. March 2007, 23:08:13

GT500

GT500.org

Posts: 3478

Sweet...

Much thanks to Sombria and d.i.z. for this great new script.

BTW: This is going to end up with it's own page on my site as well. wink

22. March 2007, 23:54:24

DynaBMan

Posts: 978

That did the trick. Thanks for the tip.
LJ
My best friend is my wife!!

Political Realities

23. March 2007, 00:20:20

GT500

GT500.org

Posts: 3478

OK, the page is ready.

Check it over, and see if I made any mistakes. I used the feature list from Orangoo Spell Check 2 in my description, so if any of those features no longer apply, then let me know. wink

23. March 2007, 02:41:51

DynaBMan

Posts: 978

Is there a way to hide the language choice dialog? I will not be using a language other than English.
LJ
My best friend is my wife!!

Political Realities

23. March 2007, 03:00:14

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

I can agree with that, There is a much larger button(?) for changing the language than there is for initiating the spell check. I will never be changing the language.

I can see this as a feature for multi-lingual people, but I would prefer the setting to be in the script like the choice of engine is.
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

23. March 2007, 04:19:55

GT500

GT500.org

Posts: 3478

Originally posted by Saddle Magic:

I can agree with that, There is a much larger button(?) for changing the language than there is for initiating the spell check. I will never be changing the language.

I can see this as a feature for multi-lingual people, but I would prefer the setting to be in the script like the choice of engine is.



While I don't mind the language selection drop-down, I too would probably never use it.

Could we instead have a flag (probably a half-US and half-UK flag would be best) that a user can mouse over, and then a list of languages (each with a flag as an icon) would pop up. The country's flag that represents the current selected language would then replace the half-US/half-UK flag as the icon to activate the popup, indicating that the selected language had been changed. In LTR mode this flag icon could go to the right of the "activate spellchecker" button, and in RTL mode it could switch sides, so that it was not in the way of the user's mouse when they tried to start the spell check.

Also, has anyone considered a script that doesn't require user interaction to start checking spelling? You know, an as-you-type kind of thing?

23. March 2007, 04:36:12

AyushJ

Posts: 4754

the language select element is between lines 313-327 so if you want to remove it, comment the line 325:
line 325: 	this.navBar.appendChild(tmp);

23. March 2007, 04:53:02

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

Originally posted by AyushJ:

the language select element is between lines 313-327 so if you want to remove it, comment the line 325:

line 325:     this.navBar.appendChild(tmp);


Thank you, that worked quite nicely smile
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

23. March 2007, 05:33:35 (edited)

GT500

GT500.org

Posts: 3478

Originally posted by AyushJ:

the language select element is between lines 313-327 so if you want to remove it, comment the line 325:

line 325:     this.navBar.appendChild(tmp);



Very good. Thanks for the suggestion. wink

There are now two versions of OSpell available for download on my site.

BTW: Does OSpell automatically load the language that the user's OS is using, or is English always the default?

23. March 2007, 09:51:25 (edited)

drlaunch

Traveler from Beyond

Posts: 1063

Looks good. But it doesn't work for me. I'm using build 8758 for Windows.

Update:
Perhaps it's one of my scripts. Gonna check which files I have to remove.

Update:
I removed some scripts and now it's working like a charm. I suppose the interface could be improved. That listbox could be replaced with a flag instead as GT500 says. And I would prefer if the animation was displayed by the tab instead of in the text area.

23. March 2007, 09:26:42

ThunderFire

Banned user

OK, the script as I've mentioned in another thread, doesn't work for me.

When I focus on a text area immediately I get this error: OSpell-0.jpg

Closing this window I immediately get the next error: OSpell-1.jpg

Closing also this I get a gray page, that I have to close: OSpell-2.jpg

The same happens for all options in Line 12 (Google, Orangoo, etc..)

I am using Windows XP (MCE) - SP2 and Opera 9.10 build 8679
Opera 9.23 (build 8808) ● Windows XP PRO - SP2 (MCE) ● Platform 32-bit ● JRE 1.6 (build 1.6.0_02-b06)

23. March 2007, 09:44:21

vinczej

Az Internet zenéje

Posts: 2388

For me would be great this script, because it can handle the Hungarian (Magyar). up

But if I start the spellchecking, I have only non-stop the three red cubes with the running progress. I tested only one word, but can't end the checking. sad (I'm logged in my Gmail account.)
Opera11 (weekly)+WinXP SP2(3GhzI)+20MCable+ZA9;

23. March 2007, 10:27:26

Opera Software

d.i.z.

bug hunter

Posts: 3029

Originally posted by kesisoglou:

OK, the script as I've mentioned in another thread, doesn't work for me.When I focus on a text area immediately I get this error:


You probably have other spell checking script installed or some other user script is causing it.
This message is not from OSpell.

Originally posted by vinczej:

But if I start the spellchecking, I have only non-stop the three red cubes with the running progress. I tested only one word, but can't end the checking. (I'm logged in my Gmail account.)


There must be some error message in Message Console. Please check that.

Originally posted by GT500:

BTW: Does OSpell automatically load the language that the user's OS is using, or is English always the default?


After first use it will remember last used language (if you have cookies enabled).

23. March 2007, 12:35:52

ThunderFire

Banned user

Originally posted by d.i.z.:

Originally posted by kesisoglou:

OK, the script as I've mentioned in another thread, doesn't work for me. When I focus on a text area immediately I get this error:


You probably have other spell checking script installed or some other user script is causing it.
This message is not from OSpell.


I don't have any other spellchecker, so that's is ruled out.

There might be an interaction with another script, but I have the absolute minimum (i.e. what I *really* need) so I can't change that.

So I guess I will stick to v3 of the other spellchecker.
Opera 9.23 (build 8808) ● Windows XP PRO - SP2 (MCE) ● Platform 32-bit ● JRE 1.6 (build 1.6.0_02-b06)

23. March 2007, 13:21:43 (edited)

vinczej

Az Internet zenéje

Posts: 2388

It can be a base, that the Orangoo v2 (orangoo.spell.inline.js) works fine.

But Orangoo v3 (orangoo_opera_v3.js and the two a-lib-...) and the Ospell spellchecks endlessly. It's any common in Ov3 with Ospell, that can cause the problem on my PC? (Any proxy or firewall?)
Opera11 (weekly)+WinXP SP2(3GhzI)+20MCable+ZA9;

23. March 2007, 17:34:13

vinczej

Az Internet zenéje

Posts: 2388

Great! At home works fine the Spellchecker, even in Hungarian, too. Congrats for co-authors! I love it! It's super in design and function! up

(Probably, at work can be any authority problem. I'll search the cause.)
Opera11 (weekly)+WinXP SP2(3GhzI)+20MCable+ZA9;

23. March 2007, 18:39:36

GT500

GT500.org

Posts: 3478

Originally posted by vinczej:

(Probably, at work can be any authority problem. I'll search the cause.)



Do you still have one of the old versions installed? I know I mentioned it on my site, but they might interfere with each other. It's best to remove the old versions before trying to use OSpell. wink

23. March 2007, 19:29:03

vinczej

Az Internet zenéje

Posts: 2388

Originally posted by GT500:

Do you still have one of the old versions installed? I know I mentioned it on my site, but they might interfere with each other. It's best to remove the old versions before trying to use OSpell.



At work I removed the old Orangoo, and tried to use Orangoo v3 and Ospell. Fortunatelly at home work everything fine.
Opera11 (weekly)+WinXP SP2(3GhzI)+20MCable+ZA9;

23. March 2007, 19:49:56

GT500

GT500.org

Posts: 3478

Originally posted by vinczej:

At work I removed the old Orangoo, and tried to use Orangoo v3 and Ospell. Fortunatelly at home work everything fine.



Do you have any other scripts installed for modifying text areas or text fields?

I assume that you have tried removing any other scripts from your UserJS folder, and checking to see if it works by itself?

23. March 2007, 19:58:21

vinczej

Az Internet zenéje

Posts: 2388

Originally posted by GT500:

Do you have any other scripts installed for modifying text areas or text fields?I assume that you have tried removing any other scripts from your UserJS folder, and checking to see if it works by itself?



Monday I'll try lonely the ospell.js at work. Just as well the UserJSs can be the difference between at work and at home.
Opera11 (weekly)+WinXP SP2(3GhzI)+20MCable+ZA9;

23. March 2007, 20:09:41

GT500

GT500.org

Posts: 3478

Originally posted by vinczej:

Monday I'll try lonely the ospell.js at work. Just as well the UserJSs can be the difference between at work and at home.



OK. With any luck you'll be able to figure this out easily. wink

24. March 2007, 02:53:40

Stevie1

Posts: 20

d.i.z this is just plain great, concreats to you for the imho best spell checking script available.
i also like the gfx with the shadow, very stylish!

greets stevie

24. March 2007, 03:03:55

Moderator

Tamil

:-(|)

Posts: 115306

When I click inside textarea http://fearphage.com/ is requested. Why?

24. March 2007, 03:14:55

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

You have your choice of spell check engines, open the script in an editor and take a look.
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

24. March 2007, 03:34:27

Moderator

Tamil

:-(|)

Posts: 115306

I already saw it and configured to use fearphage server. My question is why it is requesting even before clicking spell check icon?

24. March 2007, 03:39:53

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

It contacts when you focus on a text field, I'm guessing that is how its made to work.

It does that for the forum search field too left
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

24. March 2007, 03:46:58

GaaraZanta

E Pluribus Unum

Posts: 303

Great new interface, cleaners and works faster for me. I can't thank you enough d.i.z. for this, though still hoping that the Opera devs are able to implement inline spellchecking. The large thread in the wishlist section seems to indicate that it is something that the community really wants.
TheSimExchange

"Those who cannot remember the past are condemned to repeat it."-George Santayana

24. March 2007, 03:56:38

Moderator

Tamil

:-(|)

Posts: 115306

Originally posted by Saddle Magic:

I'm guessing that is how its made to work.

Let's wait for d.i.z. answer.

24. March 2007, 04:59:41

fearphage

Trained Swordsman of Unwanted Opera Termination

Posts: 2234

Originally posted by Saddle Magic:

It contacts when you focus on a text field, I'm guessing that is how its made to work.



This is a setting (line 18):
var ENABLED_ELEMS = { textarea: true, input: false };
Changing you line 18 to match this will only make the spellchecker target textarea elements.
Another "hidden" setting/feature (line 15):
var ENABLED_LANGS = ['en','fr'];
This makes it so only English and french will ever be in my drop down menu. Note: You have to remove the 2 '//' from the beginning of the line.
Always latest weekly; XP Pro SP2
My bugs / disable RSS subscription prompt (This will disable email and chat as well) / Receive emailed copies of your bug reports

quote from desktopteam blog Feb 23 2007 06:49.36 (direct link to comment)

Originally posted by borg:

we will not be satisfied before we have the best developer tools in the industry

Source: Mozilla Links - 5 things I’d like to see in Opera

Originally posted by Percy Cabello:

One of the main reasons I prefer Firefox is that it starts from the belief that it can’t be the ideal browser for everybody

25. March 2007, 00:59:21 (edited)

Opera Software

d.i.z.

bug hunter

Posts: 3029

Originally posted by Tamil:

When I click inside textarea http://fearphage.com/[gmail/orangoo] is requested. Why?


Script connects to spell checking server to retrieve cookie that holds last used language.
This is made like this, so that cookie won't have to be stored for every page independently.

Some storage for userjs (like greasemonkey have) would be very useful here.

24. March 2007, 12:38:13

ViperAFK

Posts: 332

I can't get any fo these spell checkers to work, absolutely nothing happens. I have userJS enabled, and the script is saved as a .js file in the correct folder, I am also logged into gmail. I do not have more than one active either, this is the only one in my js folder.

24. March 2007, 13:31:02

amix3k

Posts: 6

Well done!

Sombria is one of the coolest females programmers in tha world smile

24. March 2007, 17:00:21

GT500

GT500.org

Posts: 3478

Originally posted by ViperAFK:

I can't get any fo these spell checkers to work, absolutely nothing happens. I have userJS enabled, and the script is saved as a .js file in the correct folder, I am also logged into gmail. I do not have more than one active either, this is the only one in my js folder.



Have you tried changing which spell check engine the script uses? Check line #12 of the script. The comment just above line #12 should explain the settings. wink

25. March 2007, 00:24:43

ThunderFire

Banned user

After spending some time tracing back the problems that I have with the spell checker, I've found out that there is some interaction with my other scripts.

Specifically "ospell.js" interacts with the "get-link-info.js" script and produces the errors I've mentioned on my previous post.

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.
Opera 9.23 (build 8808) ● Windows XP PRO - SP2 (MCE) ● Platform 32-bit ● JRE 1.6 (build 1.6.0_02-b06)

25. March 2007, 00:45:54

Saddle Magic

Psycho Chicken What_The_Cluck

Posts: 19687

Originally posted by kesisoglou:

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.


You only need to read this thread to find the option, http://my.opera.com/community/forums/findpost.pl?id=1965197
Opera 12.02 Build 1578 | 3.00 GHz Pentium 4 | 2 GB DDR | WinXP Pro sp3 | 10 GB access | 22" Widescreen LCD, Synaptics Touchpad & $5 Keyboard

25. March 2007, 01:15:02

GT500

GT500.org

Posts: 3478

Originally posted by kesisoglou:

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.



Actually that's not an error. The script is supposed to do that.

And just for reference, in programmer-speak, the one-line fields are typically referred to as "text fields" while the multi-line ones are "text areas". wink

I actually find it very important for a spell checking script to check text fields as well as text areas. With Opera's default spell checking, I can't check text fields, which drives me crazy.

25. March 2007, 01:50:05

Sombria

Posts: 551

Originally posted by amix3k:

Well done! Sombria is one of the coolest females programmers in tha world

Nice to hear it wink Thanks for the coolest online spell checker smile

Originally posted by kesisoglou:

Specifically "ospell.js" interacts with the "get-link-info.js" script and produces the errors I've mentioned on my previous post.

I think that "get-link-info.js" interacts with scripts that use postMessage method e.g. with one of my favourites Operapedia. Report it to the author.

Originally posted by GT500:

OK, the page is ready. Check it over, and see if I made any mistakes. I used the feature list from Orangoo Spell Check 2 in my description, so if any of those features no longer apply, then let me know.

Thanks, GT500.
Increases height of small textareas <- Not implemented.
Prevents submitting when spellcheck is active <- No longer necessary.

Originally posted by kesisoglou:

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.

Maybe this option should be disabled by default confused

25. March 2007, 01:55:38

ThunderFire

Banned user

Originally posted by Saddle Magic:

Originally posted by kesisoglou:

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.


You only need to read this thread to find the option, http://my.opera.com/community/forums/findpost.pl?id=1965197


Actually that was a false alarm, a mistake from my end.

I've opened the code and edited out the option, but I didn't refreshed the page, and Opera had loaded in memory the previous script. So the behavior insisted to my puzzlement, so I posted it. That's what happens if you spend so much time in front of the screen smile
Opera 9.23 (build 8808) ● Windows XP PRO - SP2 (MCE) ● Platform 32-bit ● JRE 1.6 (build 1.6.0_02-b06)

25. March 2007, 02:03:04

ThunderFire

Banned user

Originally posted by GT500:

Originally posted by kesisoglou:

Also "ospell.js" seem to appear also on any text area, like the search fields in Google, the search field here at the forum etc. That's an error it needs to be fixed.


Actually that's not an error. The script is supposed to do that.


Yes, check my answer to Saddle Magic, it was my mistake this post.

Originally posted by GT500:

And just for reference, in programmer-speak, the one-line fields are typically referred to as "text fields" while the multi-line ones are "text areas". wink


Right! I was so tired when I wrote this, I was ready to type text..thingy! Then I thought "well this is an area" so... smile

Originally posted by GT500:

I actually find it very important for a spell checking script to check text fields as well as text areas. With Opera's default spell checking, I can't check text fields, which drives me crazy.


That's a good thing, but usually messes up the page. Usually the text fields are packed with other text around them and the speller goes on top of them. I haven't decide yet if I'll remove it or not. I left it there and I am trying to see how much it's getting on my nerves. The only true test from a user point of view, if a program works right! smile
Opera 9.23 (build 8808) ● Windows XP PRO - SP2 (MCE) ● Platform 32-bit ● JRE 1.6 (build 1.6.0_02-b06)

Forums » General Opera topics » User JavaScript