Skip to content

Instantly share code, notes, and snippets.

@williammustaffa
Last active May 3, 2018 12:56
Show Gist options
  • Save williammustaffa/1dd954abc1005adc0c3f24098af0e933 to your computer and use it in GitHub Desktop.
Save williammustaffa/1dd954abc1005adc0c3f24098af0e933 to your computer and use it in GitHub Desktop.
/**
* Usage:
* Go to https://objectedge.slack.com/files/{username}
* and run this code in the browser console
*/
(function() {
var time = new Date().getTime();
var url = {
list: "/api/files.list?t=" + time,
del: "/api/files.delete?t=" + time
};
var get_files_data = {
user: boot_data.user_id,
types: "all", // Or "images"
token: boot_data.api_token,
count: 1000
};
var delete_files = function(data) {
if (data.files && data.files.length > 0) {
var total = data.files.length;
data.files.forEach(function(file, index) {
var file_data = {
file: file.id,
token: boot_data.api_token
};
$.post(url.del, file_data, function() {
console.log("Deleted:", file.name);
if (total == index + 1) request_list();
});
});
} else {
console.log("Done!");
}
};
var request_list = function() {
$.post(url.list, get_files_data, delete_files);
}
request_list();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment