[UserScript] Advanced Context Sentence

I really don’t understand why you made a script for example sentences in Bunpro, they already have audio.
anyway can you please share your script with me? i tired fetching using the url but with no luck, looks like it only works from the browser not the js code. 教えて下さい、クミレイ先輩!

Thank you for your hard work! We will actually look at those sentences now! :smiling_face_with_three_hearts:
I couldn’t get the audio to work on Opera though, I am usually using that one.

1 Like

They don’t have it for all sentences yet, and when I made it they didn’t have audio for many.

Oh, looks like I forgot part of the trick. Sorry, it was a long time ago and I didn’t really understand the trick to it at the time either.

// In order to avoid getting 404 for the audio you need to remove the referrer
var remRef = document.createElement('meta');
remRef.name = 'referrer';
remRef.content = 'no-referrer';
document.querySelector('head').append(remRef);

// The way I did it was create audio and source elements containing the link
var audio = '<audio class="TTS" controls>'+
            '    <source src="https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=ja&total=1&idx=0&q='+sentence+'" type="audio/mpeg">'+
            '</audio>'

// Then I just inserted the element into the page
$(elem).after(audio);
2 Likes

Finally got to try this out, I love it! Does exactly what I wanted when I suggested the extension and the audio is a nice addition. I’m going to get a lot of use out of this :grin:

I did have to make one change to the audio section; in the script the rate is set to 11, but on Firefox at least the default rate should be 1 (the audio was playing really fast). After doing that, my home computer was able to play the audio just fine. For some reason my computer at work isn’t installing the speech synthesizers from the Japanese language pack, and since Firefox uses the device’s speech synth nothing would play. So potentially an improvement might be to check the window.speechSynthesis.getVoices() for a voice with lang ‘ja-JP’ and give some form of alert if it doesn’t exist? Note that you may have to call getVoices twice, it looks like the initial call returns an empty list for some reason. Chrome looks like it has a Japanese voice synth built in so audio shouldn’t be a problem for that browser.

1 Like

NIce script!

It seems to have a conflict with the “Markdown Notes” script (or maybe that was only because I had a modified version of that script, who knows) so I disabled the markdown script.

One thing I found confusing was the color coding: based on WaniKani standards I initially thought that pink = kanji in Apprentice state and purple = kanji in Guru state. I know that this is explained in your description but I would be willing to bet that I’m not the only user who didn’t read the whole thing before installing the script :wink:

But those were super minor issues, all in all it seems super helpful. Thank you!

1 Like

Thanks! I’m going to implement next then, I’m planing to make it the default and fall back to the browser’s audio in case of any error ( which will definitely happen if google changed a single thing in the url )

Glad you liked it, for some reason i can’t install Opera on my Mac to test it for you. but I’m planing on using google translator’s voice any way and I hope it will somehow fix it for you

what a detailed review. strange, I use firefox as my default browser and found that rate 11 is the best and most natural. maybe it’s different from machine to machine or version to version? anyway, as I told Floregaku, I’m planing to use google translator’s voice. it’s much better and browser-independent

it would be hard to test compatibilities with other scripts, but I will have a look at this particular one for you since you brought it up.
Edit: I tested Markdown Notes but didn’t encounter any conflict, is it this script or am i wrong?

to be honest I’m not proud of the color selection at all, in fact i hate it. but what color would you give to a locked kanji? tell me what you think

1 Like

Maybe I was using an outdated copy then because that is the script. I’m really sorry for wasting your time… :confused:But thanks a lot for checking!

Since they are not active yet, I would have expected them to be gray. Usually I would say bold and gray but that might not work well with kanji (never tried it and right now I’m on mobile otherwise I‘d try it now). The special highlighting for „hey, you are supposed to know this one!“ is really helpful but it loses a lot of its „specialness“ since purple and pink are so similar (both in hue and expected meaning). That‘s my opinion at least. Colors… almost everyone has an opinion :slightly_smiling_face:

Don’t be, i did it during my job so you wasted my employer’s time not mine.

I will try gray and see

1 Like

Thanks for this script!

Colours are obviously a personal choice; I’d choose green/red as known/unknown, as they are fairly-universally known as yes/no or stop/go colours.

Would it be possible to make the colours user-selectable, and/or point us to where we can manually modify the script to set the colours?

You’re right but I wanted colors that matches the wanikani’s aesthetics

Consider it done
Edit: it’s done now, version 1.20!

1 Like

I’m curious to know what you said now…

Brilliant, thank you!

1 Like

3 Likes

Woah??!!
That seems like a bug. Or is it a feature?

1 Like

It’s a feature. You won’t be able to do it once the post is actually deleted after 24 hours.

2 Likes

I HAD NO IDEA

2 Likes

Thanks for this script, actually made me sit at my computer for today’s lessons instead of lazing away in bed until I was done.:smiley:

Short questions - there were some issues with the audio speed before. Is it possible to change the speed the google voice speaks at? It’s very slow on my end.

Another question: is it possible to remove the underscore on the link? On some kanji it totally changes the meaning.

example

By that I mean the 1st sentence, in particular 牛乳. I first read 生乳, which is also a word that exists. Totally tripped me up on even understanding what google was saying, because I was expecting to hear something different.

I wish WK would just implement showing all Kanji instead of this weird mix, maybe add Furigana where they would have gone the Kana route. Really screws up googles recognition. Anyone else notice this? (In my example above, google says, and I quote 「うしにゅう]instead of 「ぎゅうにゅう」:rofl:

1 Like

Not google sadly, i don’t have much control over thier voice.

Weird, i don’t have the lines on Firefox. I’ll fix it in the next update for you

This is one of the things i find messy in Wanikani, sometimes they show you kanji that you never learned and sometimes they show you kana for that kanji… Why…

1 Like

Still a huge improvement on not having voice at all! :smiley:

Awesome, thanks!

Right? So random.

Also, another thing I noticed. The gear icon that lets you change the highlight colours gets a plus one for every new item I learn. :smiley:

screenshot

Yeah that should help you get hyped and learn more items to see more gears, totally intended, a feature not a bug
tenor

2 Likes