public
Last active

Count how many Google Voice text messages you've sent

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/*
 
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++);
};

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.)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.