It’s mostly whatever for vocab but for kanji it does show every reading instead of just the one WK is looking for, which could be confusing
As @mdub1001 mentioned, it returned A LOT of meanings and allowed phrasings for many vocab subjects, and even some that it wouldn’t even accept for kanji, so I went ahead and restricted it to only primary and alternative readings (excluding ‘allowed’ readings). It’s a simple one-liner but I made a pull request in case you want to update the main script.
Thanks for the PR. I went ahead and pulled it in and published the updated script and gave you credit.
Very thankful for these fixes as I am out of town ![]()
Does this work with extra study? I currently don’t have any reviews but wanted to verify I installed the script correctly (first time), and am not seeing the star in the upper left hand corner. I’m on Edge if that matters, but I assume it works the same as Chromium.
edit: nvm, seems to be working fine for me now! I installed the script for similar reasons as other in this thread (hand injury), I’m kind of surprised wanikani doesn’t make this a standard option for accessibility reasons…
Hello, thank you for this script I’ve enjoyed using it – however I just installed it on a new laptop and it doesn’t seem to be working. I have to click the star icon every time a card shows up, it seems to reset after every card. Does anyone know of a fix? I’m on Chrome.
Is this currently working? I can’t seem to get it running with chrome on my macbook.
yes it still works
Hey all, this is my first comment ![]()
I’ve been using this userscript and it’s great, but it doesn’t work properly for lessons. If you have “type readings” on, you almost always need to refresh the page during the 2nd batch of lessons because the script would just sort of break the page. It also happens randomly during reviews.
I’m a software developer, so I fixed it for myself. My question is: what’s the standard way to contribute to these user scripts? Is there a GitHub repo I can send a pull request to? Is the owner of this still around? Should I just post a new script for the community instead?
Hey, thanks for asking. You can submit a PR here GitHub - JDurman/WaniKani-Anki-Mode
Doesn’t work anymore on Safari, at least. I think not on Chrome, either.
@JDurman I made a thread for an issue/feature request I have but on second thought, I think it mostly has to do with Anki Mode rather than other extensions.
In short: I wish I could advance immediately when I fail a card instead of having to see it twice or more (essentially until I mark it as correct), which is now the standard behavior on Wanikani.
By the way @JDurman this extension is a life saver for someone who physically can’t type so much but still wants to do Wanikani. Thanks for maintaining it.
Has anyone encountered some issues with this userscript after the latest update that broke several userscripts?
Just me or did this stop working?
The blue show answer button literally doesn’t work anymore/is not clickable at all, but only in the meaning section. In the reading slide, it does work perfectly fine, but then I have to turn it off completely and type in the meaning by hand to continue with he reviews.
I did reinstall both this script and the OpenFramework one, and did try turning off all other scripts, even tired to make it work on a different computer and a different browser… Same issue.
Any one have a solution? Thanks x
Seems to be broken after the recent site update
I’ve tried to fix it with AI. It seems to work for now.
// ==UserScript==
// @name Wanikani Anki Mode
// @namespace wkankimode
// @version 3.0.13-local
// @description Anki mode for Wanikani; DoubleCheck 3.0 Support;
// @author JDurman
// @match https://www.wanikani.com/*
// @match https://preview.wanikani.com/*
// @grant none
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @downloadURL https://update.greasyfork.org/scripts/437009/Wanikani%20Anki%20Mode.user.js
// @updateURL https://update.greasyfork.org/scripts/437009/Wanikani%20Anki%20Mode.meta.js
// ==/UserScript==
//CREDITS
//Based on original Wanikani Anki Mode script by Mempo and modifications by necul and irrelephant
//Templated the script off of the doublecheck script made by Robin Findley (rfindley).
window.ankimode = {};
(function (gobj) {
var script_name = 'AnkiMode';
var wkof_version_needed = '1.1.3';
var scriptLoading = false;
/* globals Stimulus, wkof */
const match_patterns = [
'/subjects/review',
'/subject-lessons/*/quiz',
'/subjects/lesson/quiz*',
'/subjects/extra_study*',
'/recent-mistakes/*/quiz',
];
function url_matches(patterns, url) {
patterns = patterns || match_patterns;
url = url || window.location.pathname;
if (url[0] !== '/') url = new URL(url).pathname;
return (
(Array.isArray(patterns) ? patterns : [patterns]).findIndex((pattern) => {
let regex = new RegExp(
pattern
.replace(/[.+?^${}()|[\]\\]/g, '\\$&')
.replaceAll('*', '.*')
);
return regex.test(url);
}) >= 0
);
}
function is_turbo_page() {
return (
document
.querySelector('script[type="importmap"]')
?.innerHTML.match('@hotwired/turbo') != null
);
}
function get_controller(name) {
return Stimulus.getControllerForElementAndIdentifier(
document.querySelector(`[data-controller~="${name}"]`),
name
);
}
// WaniKani 2026 compatibility helpers.
// Prefer Stimulus controller targets over old DOM ids/classes.
function refresh_quiz_input() {
try {
quiz_input = get_controller('quiz-input') || quiz_input;
} catch (e) {}
return quiz_input;
}
function real_input() {
return (
refresh_quiz_input()?.inputTarget ||
document.querySelector('#user-response')
);
}
function input_container() {
return (
refresh_quiz_input()?.inputContainerTarget ||
document.querySelector('.quiz-input__input-container')
);
}
function answer_state() {
const state = input_container()?.getAttribute('correct');
if (state === 'true') return 'correct';
if (state === 'false') return 'incorrect';
return null;
}
function submit_answer() {
const controller = refresh_quiz_input();
// Current Double-Check hooks into quiz-input submission.
// Calling the controller method keeps Anki Mode compatible with it.
if (controller && typeof controller.submitAnswer === 'function') {
controller.submitAnswer({
preventDefault() {},
stopPropagation() {},
target: controller.element,
currentTarget: controller.element,
});
return;
}
// Fallback if WK changes this again.
const form = real_input()?.closest('form');
if (form?.requestSubmit) {
form.requestSubmit();
} else {
document.querySelector('.quiz-input__submit-button')?.click();
}
}
function create_spoof_input() {
if (document.querySelector('#WKANKIMODE_answer_input')) return;
const input = real_input();
if (!input) return;
const clone = input.cloneNode(false);
clone.id = 'WKANKIMODE_answer_input';
clone.name = 'WKANKIMODE_answer_input';
clone.placeholder = 'Your Response';
// The clone should NOT become another Stimulus target.
[...clone.attributes].forEach((attr) => {
if (attr.name.startsWith('data-')) {
clone.removeAttribute(attr.name);
}
});
clone.removeAttribute('lang');
clone.removeAttribute('required');
input.insertAdjacentElement('afterend', clone);
clone.style.display = 'none';
}
function jq_real_input() {
const input = real_input();
return input ? $(input) : $();
}
if (is_turbo_page()) {
try {
app_load();
} catch (e) {}
try {
document.documentElement.addEventListener(
'turbo:load',
page_load
);
} catch (e) {}
try {
document.documentElement.addEventListener(
'turbo:before-render',
before_page_render
);
} catch (e) {}
try {
document.documentElement.addEventListener(
'turbo:frame-load',
frame_load
);
} catch (e) {}
try {
document.documentElement.addEventListener(
'turbo:before-frame-render',
before_frame_render
);
} catch (e) {}
} else {
try {
app_load();
} catch (e) {}
try {
page_load({
detail: { url: window.location.href },
target: document.documentElement,
});
} catch (e) {}
try {
frame_load({
target: document.documentElement,
});
} catch (e) {}
}
function app_load() {
if (!url_matches(match_patterns)) return;
load_script();
}
function page_load() {
if (!url_matches(match_patterns)) return;
setTimeout(() => {
if (!scriptLoading) {
load_script();
}
wkof.Menu.insert_script_link({
name: 'ankimode',
submenu: 'Settings',
title: 'Anki Mode',
on_click: open_settings,
});
}, 1);
}
function frame_load() {
if (!url_matches(match_patterns)) return;
}
function before_page_render() {}
function before_frame_render() {}
function load_script() {
scriptLoading = true;
if (!window.wkof) {
if (
confirm(
script_name +
' requires Wanikani Open Framework.\nDo you want to be forwarded to the installation instructions?'
)
) {
window.location.href =
'https://community.wanikani.com/t/instructions-installing-wanikani-open-framework/28549';
}
return;
}
if (wkof.version.compare_to(wkof_version_needed) === 'older') {
if (
confirm(
script_name +
' requires Wanikani Open Framework version ' +
wkof_version_needed +
'.\nDo you want to be forwarded to the update page?'
)
) {
window.location.href =
'https://greasyfork.org/en/scripts/38582-wanikani-open-framework';
}
return;
}
wkof.include('Menu,Settings');
wkof.ready('document,Menu,Settings').then(setup);
}
let settings;
var answerShown = false;
var firstCorrectAnswer = '';
var secondNoTriggered = false;
var ankiModeEnabled = false;
let quiz_input;
let quiz_queue;
let srs_map;
let answer_checker;
let typedAnswerJustSubmitted = true;
let additional_content;
let item_info;
let subject_info;
let quiz_audio;
let quiz_stats;
let quiz_progress;
let quiz_header;
let response_helpers;
let srs_mgr;
function setup() {
wkof.Menu.insert_script_link({
name: 'ankimode',
submenu: 'Settings',
title: 'Anki Mode',
on_click: open_settings,
});
var defaults = {
correct_hotkey: 'Digit1',
incorrect_hotkey: 'Digit2',
showAnswer_hotkey: 'Space',
doublecheck_delay_period: 1.5,
reverse_answer_btns: false,
type_readings: false,
play_reading_after_showing_answer: false,
};
return wkof.Settings.load('ankimode', defaults).then(
init_ui.bind(null, true)
);
}
function open_settings() {
var dialog = new wkof.Settings({
script_id: 'ankimode',
title: 'Anki Mode Settings',
on_save: init_ui,
pre_open: settings_preopen,
content: {
tabHotkeys: {
type: 'page',
label: 'Hotkeys',
content: {
grpHotkeys: {
type: 'group',
label: 'Hotkeys',
content: {
correct_hotkey: {
type: 'text',
label: 'Marks answer correct',
default: 'Digit1',
placeholder:
'Please press the desired key',
},
incorrect_hotkey: {
type: 'text',
label: 'Marks answer "incorrect"',
default: 'Digit2',
placeholder:
'Please press the desired key',
},
showAnswer_hotkey: {
type: 'text',
label: 'Shows answer',
default: 'Space',
placeholder:
'Please press the desired key',
},
},
},
},
},
genOptions: {
type: 'page',
label: 'Options',
content: {
gOptions: {
type: 'group',
label: 'Options',
content: {
reverse_answer_btns: {
type: 'checkbox',
label: 'Reverse Answer Buttons',
default: false,
hover_tip:
'Changes the order of the correct/incorrect buttons after showing an answer.',
},
play_reading_after_showing_answer: {
type: 'checkbox',
label:
'Play Audio After Showing Answer',
default: false,
hover_tip:
'Plays the audio of the reading after you have shown the answer.',
},
},
},
},
},
tabDoubleCheckDelay: {
type: 'page',
label: 'Double-Check Delay',
content: {
grpDelay: {
type: 'group',
label: 'Double-Check Delay',
content: {
doublecheck_delay_period: {
type: 'number',
label: 'Delay period (in seconds)',
default: 1.5,
hover_tip:
'Number of seconds to delay before allowing\nyou to advance to the next question. This should match the value in the double-check settings.',
},
},
},
},
},
tabExp: {
type: 'page',
label: 'Experimental Features',
content: {
grpDelay: {
type: 'group',
label: 'Type Readings',
content: {
type_readings: {
type: 'checkbox',
label: 'Type Readings',
default: false,
hover_tip:
'Makes it so that you have to type readings',
},
},
},
},
},
},
});
dialog.open();
}
function formatKeyCode(value) {
return value.replace('Digit', '').replace('Key', '');
}
function settings_preopen(dialog) {
dialog.dialog({ width: 525 });
$('#ankimode_dialog #ankimode_correct_hotkey').attr(
'type',
'hidden'
);
$('#ankimode_dialog #ankimode_correct_hotkey').after(
'<input id="ankimode_correct_hotkey_readonly" class="setting" type="text" placeholder="Please press the desired key" readonly="readonly" value="' +
formatKeyCode(settings.correct_hotkey) +
'"></input>'
);
$('#ankimode_dialog #ankimode_incorrect_hotkey').attr(
'type',
'hidden'
);
$('#ankimode_dialog #ankimode_incorrect_hotkey').after(
'<input id="ankimode_incorrect_hotkey_readonly" class="setting" type="text" placeholder="Please press the desired key" readonly="readonly" value="' +
formatKeyCode(settings.incorrect_hotkey) +
'"></input>'
);
$('#ankimode_dialog #ankimode_showAnswer_hotkey').attr(
'type',
'hidden'
);
$('#ankimode_dialog #ankimode_showAnswer_hotkey').after(
'<input id="ankimode_showAnswer_hotkey_readonly" class="setting" type="text" placeholder="Please press the desired key" readonly="readonly" value="' +
formatKeyCode(settings.showAnswer_hotkey) +
'"></input>'
);
$('#ankimode_dialog #ankimode_correct_hotkey_readonly').on(
'click',
function () {
$(this).val('');
$(this).on('keydown', function (event) {
$(
'#ankimode_dialog #ankimode_correct_hotkey'
).val(event.originalEvent.code);
$(this)
.val(
formatKeyCode(event.originalEvent.code)
)
.blur();
});
}
);
$('#ankimode_dialog #ankimode_incorrect_hotkey_readonly').on(
'click',
function () {
$(this).val('');
$(this).on('keydown', function (event) {
$(
'#ankimode_dialog #ankimode_incorrect_hotkey'
).val(event.originalEvent.code);
$(this)
.val(
formatKeyCode(event.originalEvent.code)
)
.blur();
});
}
);
$('#ankimode_dialog #ankimode_showAnswer_hotkey_readonly').on(
'click',
function () {
$(this).val('');
$(this).on('keydown', function (event) {
$(
'#ankimode_dialog #ankimode_showAnswer_hotkey'
).val(event.originalEvent.code);
$(this)
.val(
formatKeyCode(event.originalEvent.code)
)
.blur();
});
}
);
}
var first_time = true;
async function init_ui() {
settings = wkof.settings.ankimode;
if (first_time) {
first_time = false;
await startup();
} else {
settings.correct_hotkey = $(
'#ankimode_dialog #ankimode_correct_hotkey'
).val();
settings.incorrect_hotkey = $(
'#ankimode_dialog #ankimode_incorrect_hotkey'
).val();
settings.showAnswer_hotkey = $(
'#ankimode_dialog #ankimode_showAnswer_hotkey'
).val();
if (!$('#WKANKIMODE_answer_input').length) {
create_spoof_input();
jq_real_input().hide();
$('#WKANKIMODE_answer_input').show();
jq_real_input()
.add('#WKANKIMODE_answer_input')
.focus(function () {
var questionType = getQuestionType();
if (
questionType === 'meaning' ||
!settings.type_readings
) {
$(this).blur();
}
});
jq_real_input()
.add('#WKANKIMODE_answer_input')
.blur();
}
if (settings.type_readings) {
newQuestion();
} else {
jq_real_input().hide();
$('#WKANKIMODE_answer_input').show();
}
$('#WKANKIMODE_anki_correct').remove();
$('#WKANKIMODE_anki_incorrect').remove();
if (settings.reverse_answer_btns) {
$('<div />', {
id: 'WKANKIMODE_anki_correct',
title: 'Shortcut: K',
})
.text('Know')
.addClass('WKANKIMODE_button correct')
.on('click', answerCorrect)
.prependTo('#WKANKIMODE_buttons');
$('<div />', {
id: 'WKANKIMODE_anki_incorrect',
title: 'Shortcut: L',
})
.text("Don't know")
.addClass('WKANKIMODE_button incorrect')
.on('click', answerIncorrect)
.prependTo('#WKANKIMODE_buttons');
} else {
$('<div />', {
id: 'WKANKIMODE_anki_incorrect',
title: 'Shortcut: L',
})
.text("Don't know")
.addClass('WKANKIMODE_button incorrect')
.on('click', answerIncorrect)
.prependTo('#WKANKIMODE_buttons');
$('<div />', {
id: 'WKANKIMODE_anki_correct',
title: 'Shortcut: K',
})
.text('Know')
.addClass('WKANKIMODE_button correct')
.on('click', answerCorrect)
.prependTo('#WKANKIMODE_buttons');
}
newQuestion();
}
var ankimodestate =
localStorage.getItem('ankimodestate');
if (
ankimodestate === 'false' ||
ankimodestate === 'true'
) {
localStorage.removeItem('ankimodestate');
settings.ankimode_enabled =
ankimodestate === 'true';
wkof.Settings.save('ankimode');
}
if (settings.ankimode_enabled) {
$('#anki-mode').addClass('anki-active');
} else {
$('#anki-mode').removeClass('anki-active');
}
}
async function startup() {
quiz_input = get_controller('quiz-input');
quiz_queue = get_controller('quiz-queue');
try {
additional_content =
get_controller('additional-content');
} catch (e) {}
try {
item_info = get_controller('item-info');
} catch (e) {}
try {
subject_info = get_controller('subject-info');
} catch (e) {}
try {
quiz_audio = get_controller('quiz-audio');
} catch (e) {}
try {
quiz_stats = get_controller('quiz-statistics');
} catch (e) {}
try {
quiz_progress = get_controller('quiz-progress');
} catch (e) {}
try {
quiz_header = get_controller('quiz-header');
} catch (e) {}
try {
response_helpers = await importShim(
'lib/answer_checker/utils/response_helpers'
);
} catch (e) {}
try {
answer_checker = Stimulus.controllers.find(
(c) => c.answerChecker
)?.answerChecker;
if (!answer_checker) {
let AnswerChecker = (
await importShim(
'lib/answer_checker/answer_checker'
)
).default;
answer_checker = new AnswerChecker();
}
} catch (e) {}
try {
if (quiz_queue?.hasSubjectIdsWithSRSTarget) {
srs_mgr = quiz_queue.quizQueue.srsManager;
} else {
srs_mgr = undefined;
}
} catch (e) {
srs_mgr = undefined;
}
if (window.doublecheck) {
$('head').append(
'<style>' +
doubleCheckCssModification +
'</style>'
);
} else {
$('head').append('<style>' + css + '</style>');
}
$('head').append(
'<style>#anki-mode.anki-active {color:#ff0; opacity:1.0;} #anki-mode { color:#fff;}</style>'
);
if (settings.ankimode_enabled) {
$('.character-header__menu-navigation').append(
'<a id="anki-mode" href="#" class="anki-active"><svg class="wk-icon wk-icon--star" title="Anki Mode - This allows you to turn on or off anki mode." viewBox="0 0 500 500" aria-hidden="true"><use href="#wk-icon__star"></use></svg></a>'
);
} else {
$('.character-header__menu-navigation').append(
'<a id="anki-mode" href="#"><svg class="wk-icon wk-icon--star" title="Anki Mode - This allows you to turn on or off anki mode." viewBox="0 0 500 500" aria-hidden="true"><use href="#wk-icon__star"></use></svg></a>'
);
}
$('#anki-mode').on('click', ankimode_clicked);
$('<div />', {
id: 'WKANKIMODE_buttons',
})
.addClass('WKANKIMODE_buttons')
.prependTo('#additional-content');
if (settings.reverse_answer_btns) {
$('<div />', {
id: 'WKANKIMODE_anki_correct',
title: 'Shortcut: K',
})
.text('Know')
.addClass('WKANKIMODE_button correct')
.on('click', answerCorrect)
.prependTo('#WKANKIMODE_buttons');
$('<div />', {
id: 'WKANKIMODE_anki_incorrect',
title: 'Shortcut: L',
})
.text("Don't know")
.addClass('WKANKIMODE_button incorrect')
.on('click', answerIncorrect)
.prependTo('#WKANKIMODE_buttons');
} else {
$('<div />', {
id: 'WKANKIMODE_anki_incorrect',
title: 'Shortcut: L',
})
.text("Don't know")
.addClass('WKANKIMODE_button incorrect')
.on('click', answerIncorrect)
.prependTo('#WKANKIMODE_buttons');
$('<div />', {
id: 'WKANKIMODE_anki_correct',
title: 'Shortcut: K',
})
.text('Know')
.addClass('WKANKIMODE_button correct')
.on('click', answerCorrect)
.prependTo('#WKANKIMODE_buttons');
}
$('<div />', {
id: 'WKANKIMODE_anki_show',
title: 'Shortcut: Space',
})
.text('Show Answer')
.addClass('WKANKIMODE_button show')
.on('click', showAnswer)
.prependTo('#WKANKIMODE_buttons');
$('<div />', {
id: 'WKANKIMODE_anki_next',
})
.text('Next')
.addClass('WKANKIMODE_button next')
.on('click', nextAnswer)
.prependTo('#WKANKIMODE_buttons');
if (window.doublecheck) {
$('body').on(
'click',
'#option-retype',
function () {
if (settings.ankimode_enabled) {
newQuestion();
}
}
);
}
bindHotkeys();
settings.ankimode_enabled
? ankimode_start()
: ankimode_stop();
}
function ankimode_clicked() {
settings.ankimode_enabled =
!settings.ankimode_enabled;
wkof.Settings.save('ankimode');
$('#anki-mode').toggleClass(
'anki-active',
settings.ankimode_enabled
);
settings.ankimode_enabled
? ankimode_start()
: ankimode_stop();
return false;
}
function ankimode_start() {
ankiModeEnabled = true;
create_spoof_input();
jq_real_input().hide();
$('#WKANKIMODE_answer_input').show();
window.addEventListener(
'willShowNextQuestion',
newQuestion
);
$('#answer-form button').hide();
jq_real_input()
.add('#WKANKIMODE_answer_input')
.off('focus.ankimode')
.on('focus.ankimode', function () {
var questionType = getQuestionType();
if (
questionType === 'meaning' ||
!settings.type_readings
) {
$(this).blur();
}
});
jq_real_input()
.add('#WKANKIMODE_answer_input')
.blur();
newQuestion();
}
function ankimode_stop() {
ankiModeEnabled = false;
jq_real_input().off('focus.ankimode');
$('#answer-form button').show();
$('.WKANKIMODE_button.correct').hide();
$('.WKANKIMODE_button.incorrect').hide();
$('.WKANKIMODE_button.show').hide();
$('.WKANKIMODE_button.next').hide();
jq_real_input().focus();
if (!answer_state()) {
jq_real_input().val('');
}
$('#WKANKIMODE_answer_input').remove();
jq_real_input().show();
}
function getCurrentItem() {
refresh_quiz_input();
return quiz_input?.currentSubject;
}
function getQuestionType() {
refresh_quiz_input();
return quiz_input?.currentQuestionType;
}
function playAudio(reading) {
var questionType = getQuestionType();
if (questionType !== 'meaning') {
let readings = getCurrentItem()?.readings;
if (readings && readings.length > 0) {
if (settings.type_readings) {
reading = jq_real_input().val();
}
let pronunciation = readings.filter(
(a) => a.reading == reading
);
if (pronunciation.length > 0) {
let vaAudio = getRandomAudioSource(
pronunciation[0].pronunciations
).sources;
let audio = new Audio(vaAudio[0].url);
audio.play();
}
}
}
}
function getRandomAudioSource(arr) {
const randomIndex = Math.floor(
Math.random() * arr.length
);
return arr[randomIndex];
}
function newQuestion() {
if (!ankiModeEnabled) return;
refresh_quiz_input();
try {
quiz_audio = get_controller('quiz-audio');
} catch (e) {}
var questionType = getQuestionType();
secondNoTriggered = false;
typedAnswerJustSubmitted = true;
answerShown = false;
hideAnswerButtons();
create_spoof_input();
$('#WKANKIMODE_answer_input').attr(
'placeholder',
jq_real_input().attr('placeholder')
);
jq_real_input().val('');
$('#WKANKIMODE_answer_input').val('');
if (settings.type_readings) {
if (questionType === 'meaning') {
jq_real_input().hide();
$('#WKANKIMODE_answer_input').show();
} else {
$('#WKANKIMODE_answer_input').hide();
jq_real_input().show();
hideButtonsForTyping();
jq_real_input().focus();
}
} else {
jq_real_input().hide();
$('#WKANKIMODE_answer_input').show();
}
}
function showAnswer() {
if (
answer_state() !== 'correct' &&
answer_state() !== 'incorrect' &&
!answerShown
) {
firstCorrectAnswer = '';
var currentItem = getCurrentItem();
var questionType = getQuestionType();
if (!currentItem) return;
if (questionType === 'meaning') {
var answer = currentItem.meanings
.filter(
(m) =>
m.kind === 'primary' ||
m.kind === 'alternative'
)
.map((m) => m.text)
.join(', ');
try {
let synonyms =
quiz_input.quizUserSynonymsOutlet.synonymsForSubjectId(
getCurrentItem().id
);
if (synonyms && synonyms.length) {
answer +=
' (' +
synonyms.join(', ') +
')';
}
} catch (e) {}
firstCorrectAnswer =
currentItem.meanings[0].text;
jq_real_input()
.add('#WKANKIMODE_answer_input')
.val(answer);
} else {
var singleAnswer = '';
var fullAnswer = '';
singleAnswer +=
currentItem.readings[0].text;
fullAnswer = currentItem.readings
.map((x) => x.text)
.join(', ');
firstCorrectAnswer = singleAnswer;
jq_real_input().val(singleAnswer);
$('#WKANKIMODE_answer_input').val(
fullAnswer
);
}
answerShown = true;
showAnswerButtons();
if (
settings.play_reading_after_showing_answer
) {
playAudio(singleAnswer);
}
}
}
function nextAnswer() {
if (answer_state() === 'correct') {
answerCorrect();
} else if (answer_state() === 'incorrect') {
answerIncorrect();
}
}
function answerCorrect() {
if (answerShown) {
if (firstCorrectAnswer) {
jq_real_input().val(firstCorrectAnswer);
firstCorrectAnswer = '';
}
submit_answer();
answerShown = false;
if (
$('#lightning-mode.doublecheck-active')
.length == 0
) {
showNextButton();
}
return;
}
if (answer_state() === 'correct') {
submit_answer();
}
}
function answerIncorrect() {
if (answerShown) {
var questionType = getQuestionType();
if (questionType === 'meaning') {
jq_real_input()
.add('#WKANKIMODE_answer_input')
.val('xxxxxx');
} else {
jq_real_input()
.add('#WKANKIMODE_answer_input')
.val('ばつっっっ');
}
submit_answer();
answerShown = false;
showNextButton();
return;
}
if (answer_state() === 'incorrect') {
if (window.doublecheck) {
if (!secondNoTriggered) {
secondNoTriggered = true;
setTimeout(function () {
submit_answer();
secondNoTriggered = false;
}, settings.doublecheck_delay_period * 1000);
}
} else {
submit_answer();
}
}
}
function hideButtonsForTyping() {
$('.WKANKIMODE_button.correct').hide();
$('.WKANKIMODE_button.incorrect').hide();
$('.WKANKIMODE_button.show').hide();
$('.WKANKIMODE_button.next').hide();
}
function hideAnswerButtons() {
$('.WKANKIMODE_button.correct').hide();
$('.WKANKIMODE_button.incorrect').hide();
$('.WKANKIMODE_button.show').show();
$('.WKANKIMODE_button.next').hide();
}
function showAnswerButtons() {
$('.WKANKIMODE_button.correct').show();
$('.WKANKIMODE_button.incorrect').show();
$('.WKANKIMODE_button.show').hide();
$('.WKANKIMODE_button.next').hide();
}
function showNextButton() {
$('.WKANKIMODE_button.correct').hide();
$('.WKANKIMODE_button.incorrect').hide();
$('.WKANKIMODE_button.show').hide();
$('.WKANKIMODE_button.next').show();
}
function bindHotkeys() {
$('body')
.off('keydown.ankimode')
.on('keydown.ankimode', function (event) {
if (
refresh_quiz_input() &&
!$('*:focus').is(
'textarea, input'
) &&
settings.ankimode_enabled
) {
switch (event.keyCode) {
case 13:
if (
answer_state() ===
'correct' ||
answer_state() ===
'incorrect'
) {
if (
settings.type_readings
) {
if (
answer_state() ===
'incorrect'
) {
if (
typedAnswerJustSubmitted ==
true
) {
typedAnswerJustSubmitted =
false;
} else {
answerIncorrect();
}
}
} else {
hideAnswerButtons();
}
}
return;
case 27:
if (window.doublecheck) {
newQuestion();
}
return;
case 8:
if (window.doublecheck) {
newQuestion();
}
return;
default:
if (
settings.correct_hotkey ==
event.originalEvent.code
) {
event.stopPropagation();
event.preventDefault();
answerCorrect();
return;
} else if (
settings.incorrect_hotkey ==
event.originalEvent.code
) {
event.stopPropagation();
event.preventDefault();
answerIncorrect();
return;
} else if (
settings.showAnswer_hotkey ==
event.originalEvent.code
) {
event.stopPropagation();
event.preventDefault();
showAnswer();
return;
}
return;
}
}
});
}
var css = "\
#WKANKIMODE_anki { \
background-color: #e1e1e1; \
color: #3c3c3c; \
margin: 0 5px; \
width: auto; \
padding: 6px; \
} \
#WKANKIMODE_yes { \
background-color: #009900; \
margin: 0 0 0 5px; \
} \
#WKANKIMODE_no { \
background-color: #990000; \
} \
.WKANKIMODE_button { \
width: 50%; \
display: inline-block; \
text-align:center; \
font-size: 0.8125em; \
color: #FFFFFF; \
cursor: pointer; \
padding: 10px 0; \
margin-bottom: 5px; \
border: 1px solid transparent \
} \
.WKANKIMODE_buttons { \
display: flex; \
position: relative; \
width: 100%; \
} \
.WKANKIMODE_buttons .incorrect { \
background-color: #f03; \
} \
.WKANKIMODE_buttons .correct { \
background-color: #88cc00; \
} \
.WKANKIMODE_buttons .show { \
background-color: #0af; \
width:100%; \
} \
.WKANKIMODE_buttons .next { \
background-color: #363636; \
width:100%; \
} \
#WKANKIMODE_anki.hidden { \
display: none; \
}";
var doubleCheckCssModification =
css +
"\
#answer-exception { \
top:5.9em \
}";
})(window.ankimode);
Sorry, no… Double-Check is the only script that I intend to maintain. However, I might consider adding an Anki Mode option to Double-Check. I already have most of the pieces needed to make that happen. It mostly comes down to finding free time, which is extremely scarce these days.
This works, thank you
You’re a lifesaver, thanks!