reverse engineer this, and turn it into a userscript to auto complete the crosswords


var STAR_URL = "/static/1710730744/img/star.svg";
var IS_IE = (getComputedStyle(document.getElementById("ie-test")).getPropertyValue("font-size")) == "10px";
if(IS_IE){
    var svg = $('.cx svg')
    var height = svg.attr("data-height");
    var width = svg.attr("data-width");
    svg.css({
        width: width,
        height: height,
        overflow: "hidden" /* stupid ie */
    });

}
var grid = [[null, null, null, null, null, null, null, null, null, null, {"down": {"index": 12, "is_start_of_word": true}, "char": "m", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "n", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": true}, "char": "d", "across": null}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "p", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "e", "across": null}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, {"across": {"index": 7, "is_start_of_word": true, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "a", "down": null}, {"down": {"index": 5, "is_start_of_word": false}, "char": "p", "across": {"index": 7, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "t", "down": null}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "a", "down": null}, {"down": {"index": 12, "is_start_of_word": false}, "char": "l", "across": {"index": 7, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "s", "down": null}, {"across": {"index": 7, "is_start_of_word": false, "rtl": 0}, "char": "m", "down": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "r", "across": null}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "i", "across": null}, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 8, "is_start_of_word": true}, "char": "r", "across": null}, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "e", "across": null}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "s", "across": null}, null, null, {"down": {"index": 18, "is_start_of_word": true}, "char": "p", "across": null}, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 8, "is_start_of_word": false}, "char": "e", "across": null}, null, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "s", "across": null}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "t", "across": null}, null, null, {"down": {"index": 18, "is_start_of_word": false}, "char": "u", "across": null}, null, null, null, null, null, null, {"down": {"index": 17, "is_start_of_word": true}, "char": "s", "across": null}, null, null, null, {"down": {"index": 8, "is_start_of_word": false}, "char": "s", "across": null}, null, null, {"down": {"index": 4, "is_start_of_word": true}, "char": "d", "across": null}, null, null, null, null, null, null, null, null], [{"across": {"index": 10, "is_start_of_word": true, "rtl": 0}, "char": "s", "down": null}, {"across": {"index": 10, "is_start_of_word": false, "rtl": 0}, "char": "u", "down": null}, {"across": {"index": 10, "is_start_of_word": false, "rtl": 0}, "char": "r", "down": null}, {"across": {"index": 10, "is_start_of_word": false, "rtl": 0}, "char": "p", "down": null}, {"across": {"index": 10, "is_start_of_word": false, "rtl": 0}, "char": "l", "down": null}, {"across": {"index": 10, "is_start_of_word": false, "rtl": 0}, "char": "u", "down": null}, {"down": {"index": 5, "is_start_of_word": false}, "char": "s", "across": {"index": 10, "is_start_of_word": false, "rtl": 0}}, null, null, null, {"down": {"index": 12, "is_start_of_word": false}, "char": "i", "across": null}, null, null, {"down": {"index": 18, "is_start_of_word": false}, "char": "r", "across": null}, null, null, null, null, null, null, {"down": {"index": 17, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, {"down": {"index": 8, "is_start_of_word": false}, "char": "e", "across": null}, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "i", "across": null}, null, null, {"down": {"index": 19, "is_start_of_word": true}, "char": "d", "across": null}, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "i", "across": null}, null, {"across": {"index": 15, "is_start_of_word": true, "rtl": 0}, "char": "m", "down": {"index": 16, "is_start_of_word": true}}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"down": {"index": 12, "is_start_of_word": false}, "char": "c", "across": {"index": 15, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "r", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"down": {"index": 18, "is_start_of_word": false}, "char": "e", "across": {"index": 15, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "n", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "m", "down": null}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"down": {"index": 17, "is_start_of_word": false}, "char": "c", "across": {"index": 15, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 15, "is_start_of_word": false, "rtl": 0}, "char": "s", "down": null}, null, null, {"down": {"index": 8, "is_start_of_word": false}, "char": "r", "across": null}, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "s", "across": null}, null, {"across": {"index": 1, "is_start_of_word": true, "rtl": 0}, "char": "c", "down": null}, {"down": {"index": 19, "is_start_of_word": false}, "char": "e", "across": {"index": 1, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 1, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"across": {"index": 1, "is_start_of_word": false, "rtl": 0}, "char": "l", "down": null}, {"across": {"index": 1, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"across": {"index": 1, "is_start_of_word": false, "rtl": 0}, "char": "n", "down": null}, {"across": {"index": 1, "is_start_of_word": false, "rtl": 0}, "char": "g", "down": null}], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "o", "across": null}, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 17, "is_start_of_word": false}, "char": "i", "across": null}, null, null, null, {"down": {"index": 8, "is_start_of_word": false}, "char": "v", "across": null}, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "i", "across": null}, null, null, {"down": {"index": 19, "is_start_of_word": false}, "char": "f", "across": null}, null, null, null, null, null], [null, null, null, null, null, null, {"down": {"index": 5, "is_start_of_word": false}, "char": "n", "across": null}, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "n", "across": null}, null, null, null, null, null, null, null, null, {"down": {"index": 0, "is_start_of_word": true}, "char": "t", "across": null}, null, {"across": {"index": 11, "is_start_of_word": true, "rtl": 0}, "char": "m", "down": null}, {"down": {"index": 17, "is_start_of_word": false}, "char": "a", "across": {"index": 11, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "r", "down": null}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": {"index": 3, "is_start_of_word": true}}, {"down": {"index": 8, "is_start_of_word": false}, "char": "e", "across": {"index": 11, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"down": {"index": 4, "is_start_of_word": false}, "char": "n", "across": {"index": 11, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "m", "down": null}, {"down": {"index": 19, "is_start_of_word": false}, "char": "i", "across": {"index": 11, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 11, "is_start_of_word": false, "rtl": 0}, "char": "s", "down": {"index": 20, "is_start_of_word": true}}, null, null, null], [null, null, null, null, null, null, null, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "e", "across": null}, null, null, null, null, null, null, {"down": {"index": 9, "is_start_of_word": true}, "char": "d", "across": null}, null, {"down": {"index": 0, "is_start_of_word": false}, "char": "r", "across": null}, null, null, {"down": {"index": 17, "is_start_of_word": false}, "char": "l", "across": null}, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "l", "across": null}, null, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "f", "across": null}, null, null, {"down": {"index": 19, "is_start_of_word": false}, "char": "c", "across": null}, null, {"down": {"index": 20, "is_start_of_word": false}, "char": "u", "across": null}, null, null, null], [null, null, null, null, null, null, null, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "t", "across": null}, null, null, null, null, null, null, {"down": {"index": 9, "is_start_of_word": false}, "char": "e", "across": null}, null, {"down": {"index": 0, "is_start_of_word": false}, "char": "o", "across": null}, null, null, {"down": {"index": 17, "is_start_of_word": false}, "char": "i", "across": null}, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "i", "across": null}, null, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "l", "across": null}, null, null, {"down": {"index": 19, "is_start_of_word": false}, "char": "i", "across": null}, null, {"down": {"index": 20, "is_start_of_word": false}, "char": "p", "across": null}, null, null, null], [null, null, null, null, null, null, null, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "a", "across": null}, null, null, null, null, {"across": {"index": 2, "is_start_of_word": true, "rtl": 0}, "char": "c", "down": null}, {"across": {"index": 2, "is_start_of_word": false, "rtl": 0}, "char": "o", "down": null}, {"down": {"index": 9, "is_start_of_word": false}, "char": "m", "across": {"index": 2, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 2, "is_start_of_word": false, "rtl": 0}, "char": "m", "down": null}, {"down": {"index": 0, "is_start_of_word": false}, "char": "u", "across": {"index": 2, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 2, "is_start_of_word": false, "rtl": 0}, "char": "n", "down": null}, {"across": {"index": 2, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"down": {"index": 17, "is_start_of_word": false}, "char": "s", "across": {"index": 2, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 2, "is_start_of_word": false, "rtl": 0}, "char": "m", "down": null}, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "g", "across": null}, null, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "a", "across": null}, null, null, {"down": {"index": 19, "is_start_of_word": false}, "char": "t", "across": null}, null, {"down": {"index": 20, "is_start_of_word": false}, "char": "p", "across": null}, null, null, null], [null, null, null, null, null, null, null, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "r", "across": null}, null, null, null, null, null, null, {"down": {"index": 9, "is_start_of_word": false}, "char": "a", "across": null}, null, {"down": {"index": 0, "is_start_of_word": false}, "char": "g", "across": null}, null, null, {"down": {"index": 17, "is_start_of_word": false}, "char": "m", "across": null}, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "t", "across": null}, null, null, null, null, {"down": {"index": 20, "is_start_of_word": false}, "char": "l", "across": null}, null, null, null], [null, null, null, null, null, null, null, null, {"down": {"index": 16, "is_start_of_word": false}, "char": "y", "across": null}, null, null, null, null, null, null, {"down": {"index": 9, "is_start_of_word": false}, "char": "n", "across": null}, null, {"down": {"index": 0, "is_start_of_word": false}, "char": "h", "across": null}, null, null, null, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "p", "across": null}, null, {"down": {"index": 14, "is_start_of_word": true}, "char": "c", "across": null}, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "i", "across": null}, null, null, null, null, {"down": {"index": 20, "is_start_of_word": false}, "char": "y", "across": null}, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 9, "is_start_of_word": false}, "char": "d", "across": null}, null, null, null, null, null, null, {"across": {"index": 6, "is_start_of_word": true, "rtl": 0}, "char": "m", "down": null}, {"down": {"index": 3, "is_start_of_word": false}, "char": "o", "across": {"index": 6, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 6, "is_start_of_word": false, "rtl": 0}, "char": "n", "down": null}, {"down": {"index": 14, "is_start_of_word": false}, "char": "o", "across": {"index": 6, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 6, "is_start_of_word": false, "rtl": 0}, "char": "p", "down": null}, {"down": {"index": 4, "is_start_of_word": false}, "char": "o", "across": {"index": 6, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 6, "is_start_of_word": false, "rtl": 0}, "char": "l", "down": null}, {"across": {"index": 6, "is_start_of_word": false, "rtl": 0}, "char": "y", "down": null}, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "l", "across": null}, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "n", "across": null}, null, {"down": {"index": 4, "is_start_of_word": false}, "char": "n", "across": null}, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 3, "is_start_of_word": false}, "char": "y", "across": null}, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "t", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "r", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "a", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"across": {"index": 13, "is_start_of_word": true, "rtl": 0}, "char": "f", "down": null}, {"across": {"index": 13, "is_start_of_word": false, "rtl": 0}, "char": "i", "down": null}, {"across": {"index": 13, "is_start_of_word": false, "rtl": 0}, "char": "s", "down": null}, {"down": {"index": 14, "is_start_of_word": false}, "char": "c", "across": {"index": 13, "is_start_of_word": false, "rtl": 0}}, {"across": {"index": 13, "is_start_of_word": false, "rtl": 0}, "char": "a", "down": null}, {"across": {"index": 13, "is_start_of_word": false, "rtl": 0}, "char": "l", "down": null}, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "t", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "i", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "o", "across": null}, null, null, null, null, null, null, null, null, null, null], [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {"down": {"index": 14, "is_start_of_word": false}, "char": "n", "across": null}, null, null, null, null, null, null, null, null, null, null]];
var index_to_row_column = [];
var index_to_direction = {}
for(var r = 0; r < grid.length; r++){
    for(var c = 0; c < grid[r].length; c++){
        var cell = grid[r][c];
        if(cell == null) continue;
        if(cell['across'] && cell['across']['is_start_of_word']){
            index_to_row_column[cell['across']['index']] = {"row" : r, "col" : c};
            index_to_direction[cell['across']['index']] = "across"
        }

        if(cell['down'] && cell['down']['is_start_of_word']){
            index_to_row_column[cell['down']['index']] = {"row" : r, "col" : c};            
            index_to_direction[cell['down']['index']] = "down"
        }
    }
}

window.addEventListener('popstate', function(event) {
    window.location.reload()
});

function doShowAnswers(){
    var show_answers = $('#image-show-answers').prop("checked")
    if(show_answers){
        $('#show-answers-options').show();
    } else {
        $('#show-answers-options').hide();
    }
}

$('#image-show-answers').on("change", doShowAnswers);
doShowAnswers();

$('#generate-image').on("click", function(){
    var show_answers = $('#image-show-answers').prop("checked")
    if(SHOW_ANSWER_WARNING && show_answers){
        $('#refund-modal').show();
        $('#refund-modal a:first').focus();
        $('#refund-modal').data("ok", function(){
            $('#generate-image').click();
        });
    } else {
        var f = this.form;
        var params = $(f).serialize();
        $('#preview-image').attr("src", "/print/fob-unit-2-economics-2" + "?" + params)
    }
})