omidsani / Is this prime? AI!

// ==UserScript==
// @name         Is this prime? AI!
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  AI for the awesome game of isthisprime?
// @author       You
// @match        http://isthisprime.com/game/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    alert('AI enabled! Press (or hooold) "a" to auto answer! :)\nNow you can be super smart! :D');
    document.body.addEventListener('keydown',function(e) {
        if(game.ended || !game.started) {
            return;
        }
        switch(e.keyCode) {
            case 65:	// 'a'
                game.check( is_prime(BigInteger(document.getElementById("n").innerHTML)) === "prime");
                break;
        }
    });

})();