Sign up | Lost password? | Help

[ advanced search ]

[UserJS] OSpell - A Better Opera Spell Checker

Forums » Opera Community » General Opera topics » User JavaScript


Go to last post

Thursday, 22. March 2007, 20:48:26

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

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

Thursday, 22. March 2007, 21:02:52

idleskitter

avatar

relax max

Banned User

Thank you d.i.z. :cheers:

Thursday, 22. March 2007, 21:30:35

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

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?

Thursday, 22. March 2007, 21:31:48

ThalSwe

avatar

Posts: 15

Sweden

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!

Thursday, 22. March 2007, 21:42:23

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

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:

Thursday, 22. March 2007, 21:46:45

ThalSwe

avatar

Posts: 15

Sweden

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.

Thursday, 22. March 2007, 21:49:44

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?

Thursday, 22. March 2007, 22:09:27

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

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.

Thursday, 22. March 2007, 22:16:57

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.

Thursday, 22. March 2007, 22:56:34

DynaBMan

avatar

Posts: 966

USA

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

Thursday, 22. March 2007, 23:00:39

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Originally posted by DynaBMan:

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


Log in to GMail first or change ENGINE in script.

Thursday, 22. March 2007, 23:08:13

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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:

Thursday, 22. March 2007, 23:54:24

DynaBMan

avatar

Posts: 966

USA

That did the trick. Thanks for the tip.

Friday, 23. March 2007, 00:20:20

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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:

Friday, 23. March 2007, 02:41:51

DynaBMan

avatar

Posts: 966

USA

Is there a way to hide the language choice dialog? I will not be using a language other than English.

Friday, 23. March 2007, 03:00:14

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

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.

Friday, 23. March 2007, 04:19:55

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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?

Friday, 23. March 2007, 04:36:12

AyushJ

avatar

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

Friday, 23. March 2007, 04:53:02

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

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:

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

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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?

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

drlaunch

avatar

Traveler From Beyond

Posts: 1002

Norway

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.

Friday, 23. March 2007, 09:26:42

ThunderFire

avatar

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

Friday, 23. March 2007, 09:44:21

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

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. :frown: (I'm logged in my Gmail account.)

Friday, 23. March 2007, 10:27:26

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

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

Friday, 23. March 2007, 12:35:52

ThunderFire

avatar

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.

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

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

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

Friday, 23. March 2007, 17:34:13

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

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

Friday, 23. March 2007, 18:39:36

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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:

Friday, 23. March 2007, 19:29:03

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

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.

Friday, 23. March 2007, 19:49:56

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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?

Friday, 23. March 2007, 19:58:21

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

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.

Friday, 23. March 2007, 20:09:41

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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:

Saturday, 24. March 2007, 01:01:32

Tamil

avatar

Opera :-(|)

Posts: 110274

Heaven

Thanks d.i.z.

Saturday, 24. March 2007, 02:53:40

Stevie1

avatar

Posts: 15

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

Saturday, 24. March 2007, 03:03:55

Tamil

avatar

Opera :-(|)

Posts: 110274

Heaven

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

Saturday, 24. March 2007, 03:14:55

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

You have your choice of spell check engines, open the script in an editor and take a look.

Saturday, 24. March 2007, 03:34:27

Tamil

avatar

Opera :-(|)

Posts: 110274

Heaven

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

Saturday, 24. March 2007, 03:39:53

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

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:

Saturday, 24. March 2007, 03:46:58

GaaraZanta

avatar

E Pluribus Unum

Posts: 267

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.

Saturday, 24. March 2007, 03:56:38

Tamil

avatar

Opera :-(|)

Posts: 110274

Heaven

Originally posted by Saddle Magic:

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

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

Saturday, 24. March 2007, 04:59:41

fearphage

avatar

Trained Swordsman of Unwanted Opera Termination

Posts: 1997

USA

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.

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

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

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.

Saturday, 24. March 2007, 12:38:13

ViperAFK

avatar

Posts: 195

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.

Saturday, 24. March 2007, 13:31:02

amix3k

avatar

Posts: 6

Well done!

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

Saturday, 24. March 2007, 17:00:21

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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:

Sunday, 25. March 2007, 00:24:43

ThunderFire

avatar

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.

Sunday, 25. March 2007, 00:45:54

Saddle Magic

avatar

Psycho Chicken What_The_Cluck!

Posts: 19065

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

Sunday, 25. March 2007, 01:15:02

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

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.

Sunday, 25. March 2007, 01:50:05

Sombria

avatar

Posts: 548

Poland

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:

Sunday, 25. March 2007, 01:55:38

ThunderFire

avatar

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:

Sunday, 25. March 2007, 02:03:04

ThunderFire

avatar

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:

Forums » Opera Community » General Opera topics » User JavaScript