FF/Chrome extension coding difficulty


#1

Not sure if this is the right sub-forum for this, please educate me if it is indeed wrong.

I’m always checking etymology information on every new kanji I encounter on up to 4 (depending on success) different websites. This is, as you can understand, a slight hassle and something I’d love to be able to work around.


So my idea is this:

An extension with which I, when I select/highlight a kanji, can search up to four different websites for the etymology information on said kanji. All at once would be preferable but one by one would be ok too - basically if I could just write an extension for one of the sites my study life would be at least a bit easier.
Basically something similar to KanJisho: https://chrome.google.com/webstore/detail/kanjisho/biciahjimgifilnjamnjgdnealbalkle

The sites that I’d use are these:
http://www.yellowbridge.com/chinese/character-dictionary.php
http://chinese-characters.org/
http://www.chineseetymology.org/
http://www.genetickanji.com/

When I actually search for kanji on two of them I go on these links and just alter the kanji in the search field to the one I’d like to search for.

http://www.yellowbridge.com/chinese/character-etymology.php?searchChinese=1&zi=%E6%B9%AF
http://www.chineseetymology.org/CharacterEtymology.aspx?characterInput=%E8%BB%8A&submitButton1=Etymo…

That may be possible for this site too if I could translate kanji–>character code:
http://chinese-characters.org/meaning/5/5B57.html


Now my question is: how difficult would it be to write an extension for this?
Could I borrow code from another similar extension (like KanJisho) and make alterations to it to suit the above websites?
I understand if some of them would pose a bigger problem due to the website layout (especially genetickanji.com ?).

I have about zero coding experience but I’m a decently smart dude who could probably (read: not saying it’s easy but it may be easy enough for me to) learn the basics of it quick - if the basics would be sufficient, that is (and that is my question).


Thank you very much in advance!


#2

If a userscript is sufficient, it would be very simple. I’ve never written a browser extension, but it would definitely be more tedious because you have to get into writing the configuration and interface files for your add-on, in addition to programming the actual code. Although you can implement toolbar buttons etc., which is nice - but also not cross-platform! User-scripts are, and they’re also easier to write. They also allow you to add menu items, but you can’t have a dedicated icon and whatnot. It’s definitely not as pretty. Whatever you choose, Also, the community is here to help!
Anyway, the actual code logic behind your idea is pretty simple to implement.
My kanji highlighter script for example can open a new tab on WaniKani (or Jisho, if the kanji is not on WK), for all the kanji in the selected text, and that part is just a few lines of code.  It’s basically like this:
For each character in the selection: Is a kanji? If so, open tab "jisho.org?kanji=XXX"
Character code conversion would also probably  be trivial and I guess it’s a matter of googling for 2 minutes.

genetickanji might be a problem since it uses some kind of page ID for each kanji, but it would be possible to parse the website and build a conversion table for kanji <-> URL. Could be a fun challenge for you as a beginner. :wink: [The basic idea is that you would download the HTML code for the site’s kanji index, and then either use an advanced text editor, or programming skills to parse out every kanji and its URL. You would then turn this list of kanji->URL relations into a format that Javascript understands, and put it into your source code. Then you could generate any URL for every kanji on that site]

What you’re trying to do doesn’t really involve any abstract concepts that are hard to grasp for beginners, and JavaScript is relatively easy to pick up (no need to worry about computer internals!), so you won’t have a hard time, I think.
It’s reaaally late here and I need to go sleep, so hopefully I didn’t miss anything.





#3
looki said... If a userscript is sufficient, it would be very simple. I've never written a browser extension, but it would definitely be more tedious because you have to get into writing the configuration and interface files for your add-on, in addition to programming the actual code. Although you can implement toolbar buttons etc., which is nice - but also not cross-platform! User-scripts are, and they're also easier to write. They also allow you to add menu items, but you can't have a dedicated icon and whatnot. It's definitely not as pretty. Whatever you choose, Also, the community is here to help!
Anyway, the actual code logic behind your idea is pretty simple to implement.

 I think there are some extensions who don't have any settings or interface (for example the ones letting you use the old UI, no settings there).  If you don't care for the user-friendly part you can dump your settings in about:config and that should be pretty easy.

But well I suck at javascript and never wanted to do any kind of web programing so I can't really give any detail on how you can make your extension.