(Obsolete) [UserScript] WaniKani Double Check

But No Cigar is a little less hardcore than that.

Slightly off answer is just not accepted, rather than wrong; with a shaking animation.

Ahh, ok. Then just set answer.exception = true instead.

	// Shake when slightly off.
	shake_when_slightly_off: 1,

[...]

	// Close but no cigar
	if  (answer.passed && !answer.accurate && settings.shake_when_slightly_off)
		answer.exception = true;
	set_answer_state(answer, true /* show_msgs */);

Actually, also in Line about 124:

// If answer is invalid for some reason, do the shake thing.
        if (answer.exception) {
            if (!$("#answer-form form").is(":animated")) {
                $("#reviews").css("overflow-x", "hidden");
                var xlat = {onyomi:"on'yomi", kunyomi:"kun'yomi", nanori:"nanori"};
                var emph = xlat[item.emph];
                var msg;
                $("#answer-form form").effect("shake", {}, 400, function() {
                    $("#reviews").css("overflow-x", "visible");
                    if (!answer.accurate) {
                        msg = 'Your answer was a bit off. Check the '+qtype+' to make sure you are correct';
                    } else {
                        msg = 'WaniKani is looking for the '+emph+' reading';
                    }
                    $("#answer-form form").append($('<div id="answer-exception" class="answer-exception-form"><span>'+msg+'</span></div>').addClass("animated fadeInUp"));
                }).find("input").focus();
            }
            if (!answer.reset)
                return;
        }
        
        // If user requested to retype answer, reset the question.
        if (answer.reset) {
            $.jStorage.set('wrongCount', wrong_cnt);
            $.jStorage.set('questionCount', question_cnt);
            $.jStorage.set('completedCount', completed_cnt);
            $.jStorage.set('currentItem', item);
            $("#answer-exception").remove();
            $('#option-double-check').addClass('disabled').find('span').attr('title','Mark Right').find('i').attr('class','icon-thumbs-up');
            $('#option-retype').addClass('disabled');
            Srs.remove();
            state = 'first_submit';
            return;
        }

and

// Close but no cigar
	if  (answer.passed && !answer.accurate && settings.shake_when_slightly_off) {
		answer.exception = true;
        answer.reset = true;
    }

I wonder if a script can be written to modify another script? I am looking for cross-script / different authors’ compatibility.

This doesn’t seem to work in my script…

if  (isException(word, $("#user-response").val()) ) {
            var answer = {
                 exception : true,
                 reset : true
             };
            set_answer_state(answer, true /* show_msgs */);
        }

Actually, I have done my script, and it works. But, I can’t avoid editing your script. Not sure if this will be viable to be uploaded to Greasyfork?

It should be done as an all-in-one script.

Almost done, but can you allow an external script to set: ?

state = 'first_submit';

and

var answer = {
   passed : false,
   exception : true,
   reset : true
};

and perhaps msg

Those variables are only visible inside the context of Double Check due to the anonymous function wrapper. But you could modify Double Check to make them visible, such as by adding a function inside the wrapper:

gobj.set_state = function(_state){
    state = _state;
}

And in your other script:

wkdoublecheck.set_state('first_submit');
1 Like

@rfindley

There seems to be a minor issue when you entered the kun’yomi reading instead of the on’yomi one or vice versa.

WaniKani notifies you that you entered the wrong reading and gives you another try.
But with this script, after entering the correct reading the second time, it immediately skips to the next item in the queue without showing you if the answer was correct or wrong.

I’m not even sure if it removes the item from the queue, because I remember seeing the items coming up again later.

More of an annoyance than anything.

:point_right: [v2.0.8] - Fix issue where wrong (on/kun)yomi reading still moves on to next answer.

@valeth, I’m not sure if this fixes the exact issue you described, but it does fix a related issue.

If this doesn’t fix it, let me know what settings you have at the top of the script. That may make a difference in whether I can replicate the problem.

Looks like it’s fixed now.

Thanks.

1 Like

@rfindley There are two minor issues with the new version of double check (version 2.0.9):

  1. When you type the wrong reading for a kanji (kun’yomi instead of on’yomi or vice versa) and have the shake_when_slightly_off setting enabled, it says “Hmm… that’s not quite right. Typo??” instead of the normal message.
  2. When you press enter after completing the last review to go to the review summary page (either no reviews are left or with “wrap up” selected) it shows the animation for the arrow up/down Apprentice/Guru/etc. message a second time.

@rfindley Just wanted to make sure you saw my previous post.

Thanks for the reminder. I was on tablet when I saw it, and forget about it by the next time I got to my PC.

1 Like

Some more issues:

  • The input doesn’t shake when you submit an empty answer, kana in the meaning question, or English in the reading question.
  • I also had it interact strangely with Jitai once, but it seems to have fixed itself on reload, so maybe there was a timing issue. I’ll keep an eye on it.

What’s the difference between this script and “Close but no cigar”? I can see that the version of @rfindley has a lot of options and that’s great, but how much different is it from Close but no cigar?

This one added the “close but no cigar” functionality afterward. It’s primary purpose is to allow you mark wrong answers right, or right answers wrong, or try to retype an answer if you made a typo but want to make sure you really know it.

1 Like

I seem to get an error when I try to run this script. What am I doing wrong? I simply press the javascript download and click on execute.

Nevermind, I realized what I should do. Thanks for the script!

:point_right: [2.0.11] - Fix response to bad input (empty answer, non-ascii in English, ascii in Japanese)

This also fixes the duplicate SRS notification at the end of the session.

2 Likes

Hey! I’m doing my reviews and when I type in an answer, the bar doesn’t change to red or green, it just goes on to the next item. I can only figure whether I got it right by checking the percentage on the upper screen. Besides, because the next item is already displayed right after I typed an answer, I don’t have enough time to click on “Item Info”. So, even if I can guess that my answer was wrong, I can’t check the correct answer on the spot.
It goes back to normal when I deactivate this script.

1 Like

I’m having the same issue :o :frowning: