WK But No Cigar

Stops Wanikani from marking answers that are 'a bit off' as correct, makes you try again until you are right or wrong.

当前为 2015-01-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         WK But No Cigar
// @namespace    http*//www.wanikani.com/review/session
// @version      0.3
// @description  Stops Wanikani from marking answers that are 'a bit off' as correct, makes you try again until you are right or wrong.
// @author       Ethan
// @match        https://www.wanikani.com/review/session
// @grant        none
// ==/UserScript==


// look for 'exception' variable o, script outside answerChecker compares 't.emph' to onyomi and assumes kunyomi when it inevitably fails (t.emph probably doesn't exist most of the time)

function main(){
var butNoCig;
//    window.addEventListener("load", doit(), false);
    doit();
    
    function doit(){
        console.log("doit");

    answerChecker.oldEvaluate = answerChecker.evaluate;

    //stops the code from submitting the answer
    answerChecker.evaluate = function(e,t){
        console.log("wrap answerChecker");
        result = answerChecker.oldEvaluate(e,t);
        if (result.passed === !0 && result.accurate === !1){
            result.exception = !0;
            butNoCig = true;
        }return result;
    };
    
 
    // create an observer instance
//    var observer = new MutationObserver(function(mutations) {
//    mutations.forEach(function(mutation) {
//    console.log(mutation.type);
  }    

 
// configuration of the observer:
//var config = { attributes: true, childList: true, characterData: true };
 
// pass in the target node, as well as the observer options
//observer.observe(target, config);
 
// later, you can stop observing
//observer.disconnect();

      // select the target node
      var target = document.querySelector('#answer-form');

      // create text node to replace
      var cig = document.createTextNode("Close, but no cigar! Please try again.");

      
      console.log("code finished");
      target.addEventListener("DOMNodeInserted", function (ev) {

      if(document.querySelector('#answer-exception') && butNoCig){
		if(document.querySelector('#answer-form').childNodes[1].childNodes.length > 4){
			document.querySelector('#answer-form').childNodes[1].lastChild.remove()
        }
        if(document.querySelector('#answer-exception').childNodes[0].childNodes[0]){
          ReadingExNode = document.querySelector('#answer-exception').childNodes[0].childNodes[0];
          document.querySelector('#answer-exception').childNodes[0].replaceChild(cig, ReadingExNode);  
        }
        butNoCig = false;
      }
}, false);
    

}      
      
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ main +')();'));
(document.body || document.head || document.documentElement).appendChild(script);