Created
January 10, 2011 03:41
-
-
Save jameshartig/772316 to your computer and use it in GitHub Desktop.
Count how many Google Voice text messages you've sent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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++); | |
}; |
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
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.)