Google Handwriting IME API Request

When you write on the Google homepage using handwriting mode, the drawn path is sent as a POST request to Google Input Tools IME API as an array of X,Y points. Following is a sample payload request sent to the Google IME API.

 "method": "POST",
 "url": "https://www.google.com/inputtools/request?ime=handwriting",
 "postData": { "text": "{
   "device":"Chrome/19.0.1084.46 Safari/536.5",
   "options":"enable_pre_space",
   "requests":[{"writing_guide":{
     "writing_area_width":1920,
     "writing_area_height":617},
    "ink":[[[582,582,582,581,581,580],
            [273,274,275,275,276,276],
            [0,529,537,554,569,1009]]],
     "language":"en"}]}"} 

And here’s a snippet of deobfuscated JavaScript code that traces and sends your handwriting to Google IME API.

_.Qx = function () {
    if (!(0, _.Dx)()) {
        var a = (0, _.rx)(_.Mx, _.Cx.slice(0)),
            b = {
                writing_guide: {
                    writing_area_width: _.yx.width,
                    writing_area_height: _.yx.height
                },
                ink: (0, _.tc)(_.Cx, function (a) {
                    return [(0, _.tc)(a, function (a) {
                        return a.x
                    }), (0, _.tc)(a, function (a) {
                        return a.y
                    }), (0, _.tc)(a, function (a) {
                        return a.t
                    })]
                })
            }, c = (0, _.Rx)();
        c && 0 < c.length && (b.pre_context = c);
        c = window.google.kHL || "en";
        c = c.replace("-", "_");
        b.language = c;
        var b = window.JSON.stringify({
            device: window.navigator.userAgent,
            options: "enable_pre_space",
            requests: [b]
        }),
            d = new _.jx;
        _.kx.push(d);
        c && (0, _.cn)(d, "complete", c);
        (0, _.cn)(d, "ready", (0, _.Ya)(_.yda, d));
        d.lK = window.Math.max(0, 6E3);
        d.send("/inputtools/request?ime=handwriting&app=gws&cs=1",
         "POST", b, { "Content-Type": "application/json" })
    }
    _.Ux.clearRect(0, 0, _.yx.width, _.yx.height);
    _.Bx = _.o;
    _.Cx = [];
    (0, _.Vx)()
};

_.Gx = function (a) {
    var b = (new window.Date).getTime() - _.Jx;
    if (!a.touches) {
        var c = a.pageX - window.pageXOffset,
            a = a.pageY - window.pageYOffset;
        return {
            x: c,
            y: a,
            t: b
        }
    }
    c = a.touches[0].pageX - window.pageXOffset;
    a = a.touches[0].pageY - window.pageYOffset;
    return {
        x: c,
        y: a,
        t: b
    }
};

_.zx = function () {
    _.Ux.clearRect(0, 0, _.yx.width, _.yx.height);
    _.Ux.save();
    _.Ux.lineWidth = 6;
    _.Ux.fillStyle = "#4d90fe";
    _.Ux.strokeStyle = "#4d90fe";
    _.Ux.lineCap = "round";
    _.Ux.lineJoin = "round";
    _.Ux.shadowColor = "rgba(0,0,0,0.3)";
    _.Ux.shadowBlur = 3;
    _.Ux.shadowOffsetY = 2;
    for (var a = 0; a < _.Cx.length; a++)(0, _.Wx)(_.Ux, _.Cx[a]);
    _.Ux.restore()
};