Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Count how many Google Voice text messages you've sent
/*
This is assuming you don't delete text messages. This only counts the amount of text messages you have not deleted.
This may take 5 minutes or so, depending on your computer speed and how many text messages you have.
Instructions:
Visit: https://www.google.com/voice/b/0#sms/ and wait for the page to fully load.
Paste this into your Javavscript console, wait it stops and look at the last count.
If you get a 500 error and it stops, then give it a few seconds and then call resume();
*/
var page = 1;
var count = 0;
var resultsTimer = null;
var pageCounted = 0;
var timeout = 10;
var process = function() {
if (document.getElementsByClassName('gc-message-read').length == 10 && page > pageCounted && document.getElementById('gc-inbox-page-next').style.display !== "none") {
clearTimeout(resultsTimer);
count += document.getElementsByClassName('gc-message-sms-text').length;
console.log("Count(p"+page+"): "+count);
pageCounted = page;
setTimeout(function() {location.hash = "#sms/p"+(page++);}, timeout);
} else {
clearTimeout(resultsTimer);
resultsTimer = setTimeout(function() {
if (document.getElementById('gc-inbox-page-next').style.display === "none") {
count += document.getElementsByClassName('gc-message-sms-text').length;
console.log("Total text messages: "+count);
}
}, 500);
}
};
document.getElementById('gc-message-list').addEventListener('DOMNodeInserted', process, false);
if (location.hash != "#sms/p1") {
location.hash = "#sms/p"+(page++);
} else {
page = 2;
process();
}
var resume = function() {
timeout *= 1.5;
location.hash = "#sms/p"+(page++);
};
@aonphleacs

This comment has been minimized.

Copy link

commented Aug 30, 2013

This is fantastic. I found that I can also use it to count how many texts I've sent to a specific contact by searching for with:contact and then copying the hash location and replacing #sms with it. If there was a way to do that that was slightly less hacky I think it would be a fantastic addition! (I'm not sure I'm good enough at JS to do it myself, though I might try.)

@brianherman

This comment has been minimized.

Copy link

commented Jun 7, 2017

I can't get this working with the current version of google voice. Any tips? They did a redesign and the css classes changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.