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

您需要先安裝使用者腳本管理器擴展,如 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.5
// @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==


var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;

function main(){
    doit();
    
    function logMutations(){
        
        var observer = new MutationObserver(function (mutations) {
            // iterate over mutations..
            mutations.forEach(function (mutation) {
                if (mutation.addedNodes.length>0){
                    if(mutation.addedNodes.item(0).classList){
                        if(mutation.addedNodes.item(0).classList.contains("answer-exception-form")){
                            mutation.addedNodes.item(0).innerHTML=mutation.addedNodes.item(0).innerHTML.replace(/WaniKani is looking for the [oku]{1,2}n'yomi reading/,"Close, but no cigar! Please try again");
             observer.disconnect();
                            
                        }}
                }
                
                
                
            });
                           
            var highLanders = document.querySelectorAll("#answer-exception");
            if (highLanders.length > 1){ // There can be only one!!!
                for (hL=1; hL<highLanders.length; hL++){
                    highLanders[hL].parentNode.removeChild(highLanders[hL])
                }
            }
            
            
        });
        
        var settings = { 
            childList: true, subtree: true, attributes: false, characterData: false 
        }
        
        observer.observe(document.body, settings);
    }
    
    // select the target node
    
    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;
                
                logMutations();
                
            }
            return result;
        };
        
    }    
    
    
}      

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