[Userscript] Forum: IME2Furigana

ルビーテキストが好きI like ruby text :slight_smile:


Isn’t this how it’s usually written anyway?

Neat script, it’s better than my script which converts <kanji>[furigana] into ruby

Bug report: The script remembers that I turned it on, but the button is says off when I start a new post (until I click it again and it says blur)


Generally the furigana should be above the specific kanji it’s actually associated with. The exception is when the reading of the word has no association with the individual kanji, like with 明日.


In my experience they seem to center the furigana on the word whenever the reading is longer than maybe 3 or 4 kana, for a word with two kanji

I actually just saw furigana in a physical book the other day that added whitespace similar to the browser to put the furigana above just the correct kanji. But I’ve seen what you said as well for long readings. I still think that’s bad practice when the reading only has one or two characters and would fit above the correct kanji though.

1 Like

Thanks for the report, I have fixed it (version 0.3).

Regarding the positioning of the furigana, I think that a clear mapping where possible would be preferable. But as far as I know most webbrowsers except for firefox don’t support ruby well enough to do this. I’ve read through https://www.w3.org/International/articles/ruby/markup.en a while ago and the browser support doesn’t look too good.


Kinda think something like 小林こばやし looks rather better than ばやし. Also, fewer tags needed.


I think the same holds for even 四月(しがつ) and がつ


Bit of a strange question, is it possible to make this available for any discourse forum? I would love to also be able to use this on BunPro for example.

I think it should work if you just add
// @match https://community.bunpro.jp/*
after or before
// @match https://community.wanikani.com/*

That would work, I just was wondering if there was a way to detect whether you are using a discourse forum, or if that would require a complex script.

I don’t think the URL can be used as an indicator if the webpage is a discouse forum, so I would have to inject the script into every webpage and then let it guess if the page is a discourse forum. The guess part is probably not a problem, but I don’t really like the idea that the script gets injected into every webpage you visit.

1 Like

Yeah, that sounds like a bit too much effort :sweat_smile:
I’ll just copy the @ match in the script instead. :yum:

It’s not really the effort but the privacy/security concerns that make me hesitate. In addition to that I also don’t like to add unnecessary workload to every webpage, even if this workload is negligible.

Maybe I’m also worrying too much. I’m 99% sure that my script could not be exploited by malicious code, even if it were to run on your online banking website, and who would even spend the effort to think up an exploit for a userscript that only a handful of people use?

I guess if you want (and don’t blame me if the 1% case happens :stuck_out_tongue:) I could make a second version of the script that runs on every webpage.

1 Like

I think the amount of effort on your end versus the amount of effort on my end is quite disproportional. So unless you really want to do it for yourself, don’t worry about it :blush:

1 Like

Version 1.0 patch-notes:

Added furigana markup functionality

Writing <漢字>[かんじ] results in 漢字(かんじ), while writing <漢字>{かんじ} results in 漢字(かんじ).

The markup is the same as in the Easy Furigana userscript by @Kumirei.

I hope you never want to post the character sequence < something >[ something ]. If you come across such a situation, you have to disable IME2Furigana (with the F button).

IME input gets converted to furigana markup

Instead of immediately generating ruby markup and cluttering the input box with a monstrosity like <ruby lang = 'ja-JP'>振<rp>(</rp><rt>ふ</rt><rp>)</rp></ruby>り<ruby lang = 'ja-JP'>仮名<rp>(</rp><rt>がな</rt><rp>)</rp></ruby>, the IME input gets converted to furigana markup: <振>[ふ]り<仮名>[がな].

Button state is now persistent

The button state should now get shared across tabs and even sessions (unless you clear the browser data).

Important change: If you disable the IME2Furigana functionality with the F button, it does not only disable the IME input to furigana markup conversion, but also the furigana markup to ruby conversion.

If I broke something please also let me know.
Link to previous script version for downgrading in case version 1.0 doesn’t work/isn’t to your liking


Well then

I am learning a bunch of things from looking at the code of this script, thanks! I had no idea about the composition events, that’s great!

1 Like

Thanks! The hardest part for me was the injection into Discourse, because I don’t know anything about requireJS. That part was mostly trial and error, and I’m a bit worried that what I wrote there might break easily. So maybe it was a bit hasty of you to link to my script ^^ But thank you for having confidence in my script :slight_smile:

1 Like

I’m just an amateur scripter so it all looks like magic to me. I would never ever have thought of injecting. I think you mean Discourse, btw :eyes:

1 Like