Created
November 25, 2012 22:30
-
-
Save ljepson/4145688 to your computer and use it in GitHub Desktop.
Google Voice Delete
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
var voice = { | |
jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', | |
key_name: '_rnr_se', | |
key_value: function() {return jQuery('input[name="'+ voice.key_name +'"]').val()}, | |
page: 1, | |
messages: [], | |
done: false, | |
init: function() { | |
var script = document.createElement('script'), | |
head = document.getElementsByTagName('head')[0]; | |
script.src = voice.jquery; | |
script.onload = script.onreadystatechange = function(){ | |
if(!voice.done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { | |
voice.done = true; | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
voice.build(); | |
} | |
}; | |
head.appendChild(script); | |
}, | |
build: function(url) { | |
var count = 0, url = url || '/voice/b/0/inbox/recent/all'; | |
jQuery.ajax({url: url, data: {page: 'p' + voice.page}, success: function(d) { | |
count = 0; | |
var result = jQuery.parseJSON(jQuery(d).find('json').text()).messages; | |
for(m in result) { | |
count++; | |
voice.messages.push(m); | |
} | |
}}).promise().done(function() { | |
if(count > 0) { | |
voice.page = voice.page + 1; | |
voice.build(url); | |
} else { | |
console.log(voice.messages.length); | |
} | |
}); | |
}, | |
run: function(action,url,id) { | |
var key = voice.key_name, | |
value = voice.key_value(); | |
if(action === 'delete') { | |
var data = {trash: 1, messages: id}; | |
} else { | |
var data = {messages: id}; | |
} | |
data[key] = value; | |
jQuery.ajax({type: 'POST', url: url, data: data}); | |
}, | |
delete: function(id) { | |
voice.run('delete','/voice/inbox/deleteMessages/',id); | |
}, | |
forever: function(id) { | |
voice.run('forever','/voice/inbox/deleteForeverMessages/',id); | |
} | |
}; | |
voice.init(); |
To delete messages and move into trash:
for(var i in voice.messages) voice.delete(voice.messages[i])
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not responsible for whatever harm you may cause by using the scripts described here.
To delete all messages in trash forever:
voice.build('/voice/inbox/recent/trash/');
for(var i in voice.messages) voice.forever(voice.messages[i])