Skip to content

Instantly share code, notes, and snippets.

@ebobby
Last active December 17, 2015 16:39
Show Gist options
  • Save ebobby/5640665 to your computer and use it in GitHub Desktop.
Save ebobby/5640665 to your computer and use it in GitHub Desktop.
Clear all your CloudApp items. Paste this code in your browser's javascript console after signing in to http://my.cl.ly/ and simply call deleteAllItems(), it will take a while depending on the number of items you have.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Clear all your CloudApp items.
//
// Paste this code in your browser's javascript console and simply call deleteAllItems(), it will take a while
// depending on the number of items you have.
// --fms
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getToken () {
return $('input[name=authenticity_token]').first().val();
}
function getCurrentURLs () {
var urls = [];
$('input[type=checkbox]').each(
function (index, element) {
urls.push("http://my.cl.ly/items/" + $(element).val());
return;
}
);
return urls;
};
function deleteURLs (urls) {
urls.map(function (url) {
$.ajax({
url: url,
type: 'DELETE',
data: { authenticity_token: getToken() }
});
});
}
function deleteAllItems () {
var interval = setInterval(
function() {
var urls = getCurrentURLs();
console.log("Deleting " + urls.length + " items.");
if (urls.length === 0) {
clearInterval(interval);
return;
}
deleteURLs(urls);
try { $('div#pagination').find('a')[0].click(); } catch (e) {}
}, 5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment