Skip to content

Instantly share code, notes, and snippets.

@erwan
Created August 31, 2010 13:28
Show Gist options
  • Save erwan/559009 to your computer and use it in GitHub Desktop.
Save erwan/559009 to your computer and use it in GitHub Desktop.
Chrome Screencast 1
<script>
</script>
var phoneRe = /^\s*((\d{2}\s?){5})\s*$/;
var texts = document.evaluate(".//text()[normalize-space(.)!='']", document.body, null, 6, null);
for (var i = 0; i < texts.snapshotLength; i++) {
var textNode = texts.snapshotItem(i);
var text = textNode.textContent;
var m = phoneRe.exec(text);
if (m != null) {
var newText = document.createElement("a");
newText.setAttribute("href", "callto:" + m[1]);
newText.appendChild(document.createTextNode(m[0]));
textNode.parentNode.replaceChild(newText, textNode);
}
}
{
"name": "Telify",
"version": "0.1",
"description": "Click to call",
"background_page": "background.html",
"content_scripts": [{
"js": ["contentScript.js"],
"matches": ["http://*/*"]
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment