WaniKani Multiple Answer Input (2023)

Input multiple readings/meanings into Wanikani

  1. // ==UserScript==
  2. // @name WaniKani Multiple Answer Input (2023)
  3. // @namespace http://www.wanikani.com
  4. // @version 2.2.0
  5. // @description Input multiple readings/meanings into Wanikani
  6. // @author polv
  7. // @match https://www.wanikani.com/*
  8. // @match https://preview.wanikani.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=wanikani.com
  10. // @license MIT
  11. // @require https://gf.qytechs.cn/scripts/470201-wanikani-answer-checker/code/WaniKani%20Answer%20Checker.js?version=1215595
  12. // @homepage https://gf.qytechs.cn/en/scripts/466680-wanikani-multiple-answer-input-2023
  13. // @supportURL https://community.wanikani.com/t/userscript-multiple-input-answer-2023/61931
  14. // @source https://github.com/patarapolw/wanikani-userscript/blob/master/userscripts/mulitple-answer.user.js
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. // @ts-check
  19. /// <reference path="./types/answer-checker.d.ts" />
  20. (function () {
  21. 'use strict';
  22.  
  23. window.modAnswerChecker.register((e, tryCheck) => {
  24. const splitter = e.questionType === 'reading' ? /・/g : /(?:;|\/)/g;
  25. const isKanjiReading =
  26. e.item.subject_category === 'Kanji' && e.questionType === 'reading';
  27.  
  28. /** @type {Record<string, Evaluation[]>} */
  29. const evalActionMap = {};
  30.  
  31. for (const subResponse of e.response.split(splitter)) {
  32. let response = subResponse.trim();
  33. if (!response) continue;
  34.  
  35. const result = tryCheck({ ...e, response });
  36.  
  37. const sect = evalActionMap[result.action] || [];
  38. sect.push(result);
  39. evalActionMap[result.action] = sect;
  40. }
  41.  
  42. for (const actionType of ['fail', 'retry', 'pass']) {
  43. if (evalActionMap[actionType]) {
  44. const result =
  45. evalActionMap[actionType].find((r) => r.message) ||
  46. evalActionMap[actionType][0];
  47.  
  48. if (actionType === 'retry' && isKanjiReading && evalActionMap['pass']) {
  49. result.action = 'pass';
  50. }
  51.  
  52. return result;
  53. }
  54. }
  55.  
  56. return null;
  57. });
  58. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址