Hacking Google Voice Call Widget

So I recently had a client that I was building a website for, and he wanted to have it so people could call him easily from the website. I imediately thought of Google Voice. However the Google Voice Widget that Google provides was not an option mainly because it uses Flash. This would cause this responsive website to have some issues when it comes to mobile devices that don’t support Flash.

Hacking Google Voice Call Widget

The solution was to hack the Google Voice Widget and make it work without Flash. There where several languages I could have chosen but in the end I chose JavaScript.

When Google Voice Generates the Google Voice Widget HTML code it looks similair to the below.

After examining the above code we can see that making a Javascript snippet that uses Google Voice is fairly simple.

The type="application/x-shockwave-flash" indicates that it is Flash, which we already knew. The data="" is data that gets sent to the Google Voice servers. This was important to know, because without that the call could not be made. Then we have value="id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" this is our unique Google Voice ID.

After some minor trial and error I was finally able to throw together the following code.

function click2call(button_id, cid_number, cid_name) {
var iframe = document.createElement('iframe'); = 0; = 0; = 0;

var doc = null;
doc = iframe.contentDocument;
else if(iframe.contentWindow)
doc = iframe.contentWindow.document;
else if(iframe.document)
doc = iframe.document;
if(doc == null)
throw "Document not initialized";; doc.write('');doc.close();
var form = doc.createElement("form");
input = doc.createElement("input");
input.value= ""+button_id;
input = doc.createElement("input");
input.value= ""+cid_number;
input = doc.createElement("input");
input = doc.createElement("input");
input.value= "1";

I then just needed to create an HTML form for the Javascript code. The end result of the HTML form looked like the following.

As of this point in time this works. But keep in mind that Google is always changing and this may not work for ever. But I do hope that one day Google will actually make a different type of Google Voice Widget.

Post by Son Nguyen · in 29-04-2019 · view: 779