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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);