Skip to content

Instantly share code, notes, and snippets.

@Jhawins

Jhawins/starDeath.js

Last active Aug 29, 2015
Embed
What would you like to do?
Mwahahahahahaha
function fireAj(id) {
$.ajax({
type: 'POST',
url: "http://chat.stackoverflow.com/messages/" + id + "/unstar",
data : {fkey: fkey().fkey},
}).done(function(json) {
console.info('unstarred :'+ id);
});
}
function curRun(maxLength, unstarred) {
var starsDiv = $('#starred-posts')
, length = starsDiv[0].firstElementChild.firstElementChild.children.length
, unstarred = 1;
for (var i = 0; i < length; i++) {
// we finished! or... Maybe there's no one left to save
if (unstarred > maxLength || length === 0) return true;
// get to saving the day
var starID = starsDiv[0].firstElementChild.firstElementChild.children[i].id.replace('summary_', '');
var dumb409 = window.setTimeout(fireAj, i*3000, starID);
unstarred++
// out of stars go get more
if (i === length-1) {
var nextRun = window.setTimeout(curRun, i*3000, maxLength, unstarred);
console.warn('Ran out of stars!! Looking for more');
}
console.log('Sent request for :' + starID);
}
}
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.