[UserScript] WaniKani Fast Abridged Wrong/Multiple Answer

Okay, I’m able to replicate this. I’ll look into this tonight.

@DaisukeJigen,

I found the problem.
@viet, you might be interested in this, if you’re not already aware.

details

It seems jQuery UI is incompatible with one piece of Wanikani code.
In Wanikani’s UserSynonyms.addOption(), it does this:

$("<input></input>", {
    type: "text",
    autocapitalize: "none",
    autocomplete: "off",
    autocorrect: "off",
    spellcheck: "false"
})

The intent is to add each parameter in the object as an attribute on the <input> tag.

The problem is that jQuery checks each parameter to see if it matches a function name in $.fn.
In this case, jQuery UI has an Autocomplete widget that places a constructor at $.fn.autocomplete().
So, instead of adding an autocomplete="off" attribute to the <input> tag, it tries to call $.fn.autocomplete("off").

You can simulate the exact same error by doing this directly (after loading jQuery UI dynamically):

$('<input></input>').autocomplete("off")

I’m going to push a workaround into the framework tonight.

details

I’m going to dynamically remove $.fn.autocomplete after jquery_ui.js loads:

delete $.fn.autocomplete;

We’ll lose the ability to use the Autocomplete widget, but I wasn’t using it anyway, so no issue.

This makes the “add synonym” feature work like normal.

4 Likes

I’ll set up some tests today and see if we can avoid the function/attribute collision.

2 Likes

Hi! I’m not sure what I’m doing wrong but I can’t get the colors to change. I’m not one with the coding so could you tell me what to change in the code to change the colors? Thanks.

In the showBar function I believe. Not at home, so harder to check. You’d have to make a switch statement based off mode. It was a setting before, but it went away when converted to Open Framework. It’ll be making a return, but took a leave of absence to get the OF version up and running.

@DaisukeJigen,
bonkaholic’s issue turned out to be this:

    if(window.location.href == "https://www.wanikani.com" || window.location.href == "https://www.wanikani.com/dashboard"){

The location was actually https://www.wanikani.com/ (i.e. with a slash on the end), so it wasn’t installing the menu link.
You can use pathname instead of href, since it automatically adds a "/" if one isn’t present:

    if(window.location.pathname == "/" || window.location.pathname == "/dashboard"){
2 Likes

I scooted the attributes out of the short-hand element constructor and added them with a .attr({…}). The code’s live so we shouldn’t have the attribute/function name conflict anymore. (JQuery UI) Autofill away!

2 Likes

Just wanted to say that I think it is working on my end. I have the fast abridged wrong/multiple answer downloaded and on without anything strange happening with synonyms. I even was able to add synonyms during a review and out of it just fine.

New(old) settings (re)added to override the colors

Minor complaint. There seems to be some sort of coloring difference between this and ignore answer script. Before when I hit ignore answer both bars would turn orange. Now it’s just the top one, not the right answer bar.

Side effect of allowing custom colors for the second bar. Even if you don’t choose custom colors, it is still overriding with the “defaults”, and I had to !important them to get it to work. So basically, its not truely inheriting the color anymore. I noticed similar behavior with WaniKani Double-Check.
I could check if override == default and then not !important maybe…

What I usually do is look at the existing selector for the CSS that I want to modify, and the just add one extra class to the selector to make it strong enough to override the original. That way you can avoid using !important, and toggle whether CSS takes effect by adding a single upstream class.

For example,

Original rule:
#quiz li.answer {color:#f22;}

Override rule:
#quiz.custom li.answer {color:#cfc;}

$(‘#quiz’).addClass(‘custom’);

1 Like

Forgot about that way. I believe right now, I have the CSS being inline with the element manipulation I’m doing. But, making a new class in my CSS insert, and just putting the class in the span (I think it was a span anyway) next update may be a good modification.

For some reason this userscript stopped behaving properly; I have the checkboxes for “always show answers” and “only when multiple answers.”

If the term has 0 synonyms built-in though, it won’t work. I’ll get the “did you know this item has multiple answers?” text box and they won’t auto-display.

For me, it suddenly stopped showing user defined synonyms…

@jbradleyc @voidzero Looks like WK must have made some changes. Appears user synonyms have their own spot now. Fix is in the works.

Update: Should be fixed. Didn’t have any user synonyms on any of the reviews I did, so I couldn’t do a “true” test, but should be all set.

I am having a different issue now.
If I added user synonyms, it shows those correctly. But it shows the built-in synonyms as [object Object]. I’m on Firefox.

1 Like

Gosh darn it. Please hold. :telephone_receiver::musical_note:

Thank you for holding. It appears I made a stupid typo. v3.3 is live. Thank you for your patience.

3 Likes

Something’s still not working for me :frowning:

The other possible meanings are both user-added. Anything with synonyms built-in works just fine. Made sure I updated to 1.3.3.

Good news: Found it
Bad news: Fix not coming until tomorrow sometime.

1 Like