(Obsolete) [UserScript] WaniKani Double Check

@polv,
In the Item Marker script, on line 1367, change this line:

var liCount = $('#additional-content ul').children().size();

to this:

var liCount = $('#additional-content ul').children(':visible').size();
1 Like

Thanks, it now works.

Maybe, because of // @run-at document-start ?

Reading your script on Three Submit Principle, any guideline on how to make a new No Cigar? (since the old one doesn’t work with Three Submit).

Actually, I am trying to create No Cigar, not only for near-miss, but also for Some-Default-Answers-I-Don’t-Want-To-Make-It-Right, here: https://www.dropbox.com/s/o238yjizxl17d1c/blacklist.js?dl=0

@polv,
Are you wanting to make the two scripts compatible? Or make a new script with features from both?

Adding ‘No Cigar’ to Double-Check

You can add a No-Cigar option to Double-Check in the [case 'first_submit'] section. The following line is where it sets the initial answer result (line 234):

	set_answer_state(answer, true);

When you give a close-but-no-cigar answer, the answer object looks like this:

{
	passed: true,
	accurate: false,
	multipleAnswers: false,
	exception: false
}

So, if it passed, but isn’t accurate, it’s a “No Cigar”.

Start by adding an option at the top of the script:

	// Mark answer wrong when slightly off.
	change_slightly_off_to_wrong: 1,

Then in the ‘first_submit’ section, change the set_answer_state() call to:

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

Adding Blacklist

In the same part of the code, you could check your exception_array, and again set answer.passed = false.

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.