Skip to content

Instantly share code, notes, and snippets.

@ljepson
Created November 25, 2012 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljepson/4145688 to your computer and use it in GitHub Desktop.
Save ljepson/4145688 to your computer and use it in GitHub Desktop.
Google Voice Delete
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();
@ljepson
Copy link
Author

ljepson commented Nov 28, 2012

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

@ljepson
Copy link
Author

ljepson commented Nov 28, 2012

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