Greasy Fork

Greasy Fork is available in English.

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-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         WK But No Cigar
// @namespace    http*//www.wanikani.com/review/session
// @version      0.4
// @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
// @match        https://www.wanikani.com/lesson/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);