Last active
May 3, 2018 12:56
-
-
Save williammustaffa/1dd954abc1005adc0c3f24098af0e933 to your computer and use it in GitHub Desktop.
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
/** | |
* 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