[UserScript] Stay Typing after a wrong answer

After a wrong answer in a typing exercise, the next exercise will also be a typing exercise instead of a multiple-choice exercise. This is a lesser version of the “All Typing” script, since Memrise still chooses which words will be tested via typing.
Sharing it in case someone finds it useful.

// ==UserScript==
// @name         Memrise - Stay Typing
// @namespace    http://tampermonkey.net/
// @match        https://www.memrise.com/course/*/garden/*
// @match        https://www.memrise.com/garden/review/*
// @match        https://app.memrise.com/garden/review/*
// ==/UserScript==

$(document).ready(function() {

    //Vars
    var list = [];

    MEMRISE.garden._events.start.push(() => {
        MEMRISE.garden.session.box_factory.make = (function() {
            var cached_function = MEMRISE.garden.session.box_factory.make;
            return function() {
                var result = cached_function.apply(this, arguments);
                if(list.includes(arguments[0].learnable_id)){
                    change(result);
                }
                return result;
            };
        }());

        MEMRISE.garden.session.onWrong = (function() {
            var cached_function = MEMRISE.garden.session.onWrong;
            return function(){
                cached_function.apply(this, arguments);
                if(MEMRISE.garden.box.template === 'typing'){
                    var id = arguments[0].learnable_id;
                    list.push(id);
                }
            };
        }());
    });


    //Called for wrong (typing) answers
    function change(box){
        if(box.template !== "presentation" && box.template !== "copytyping"){
            console.debug("CHANGE");
            box.template = "typing";
        }
    }

});
1 Like