Skip to content

Instantly share code, notes, and snippets.

@haykuro
Last active October 14, 2020 15:06
Show Gist options
  • Save haykuro/aeb7dfbacab52ad55b436dc32f8561b2 to your computer and use it in GitHub Desktop.
Save haykuro/aeb7dfbacab52ad55b436dc32f8561b2 to your computer and use it in GitHub Desktop.
/**
* HOW TO USE:
* 1. Go to: https://YOURTEAM.slack.com/files
* 2. Open inspector for your browser.
* 3. You'll see: 2017/6/6 22:16:45.834 User id: XXXXXXXXX, team id: XXXXXXXXX
* 4. Paste user id in to where it says "USER_ID_HERE"
* 5. Copy/paste this whole script to your console.
*/
/*global
jQuery, TS
*/
(function () {
"use strict";
function deleteTimeout(fileID, time_to_wait) {
console.log('Deleting ' + fileID + ' in ' + time_to_wait);
setTimeout(function () {
console.log('Deleting ' + fileID);
TS.api.call('files.delete', {file: fileID}, function (success, data) {
if (!success) {
console.error('files.delete: FAILED');
return;
}
console.log('files.delete', data);
});
}, time_to_wait);
}
TS.api.call('files.list', {user: 'USER_ID_HERE', count: 700}, function (success, data) {
if (!success) {
console.error('files.list: FAILED');
return;
}
var i, file;
for (i = 0; i < data.files.length; i += 1) {
file = data.files[i];
deleteTimeout(file.id, ((i + 1) * 100));
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment