Skip to content

Instantly share code, notes, and snippets.

@boisei0
Last active December 1, 2018 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boisei0/bf7e5f071bf2042f8300b238a92d4f97 to your computer and use it in GitHub Desktop.
Save boisei0/bf7e5f071bf2042f8300b238a92d4f97 to your computer and use it in GitHub Desktop.
Tampermonkey script to use with https://www.slackdeletron.com
// ==UserScript==
// @name Slackdeletron file nuke
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Nuke all files in any slackdeletron search...
// @author You
// @match https://www.slackdeletron.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
var timeoutStorageVar;
var mutationObserverTargetNode = document.querySelector('.Header__Meta');
var observerOptions = {
childList: true,
subtree: true,
}
function insertNukeButtonCallback(mutationList, observer) {
mutationList.forEach((mutation) => {
if (mutation.type === 'childList') {
if (mutation.removedNodes.length !== 0) {
if (document.getElementById('NukeButton') === null) {
// Good to go
var nukeButton = document.createElement('button');
nukeButton.appendChild(document.createTextNode('Nuke all files (slowly)'));
nukeButton.id = 'NukeButon';
nukeButton.setAttribute('style', 'background: red; color: white');
nukeButton.setAttribute('class', 'Button Button__Large');
nukeButton.addEventListener('click', function() {
// alert('hi');
delFile();
});
document.getElementsByClassName('Button Button__Large')[0].parentNode.appendChild(nukeButton);
}
observer.disconnect();
return;
}
}
});
}
var mutationObserver = new MutationObserver(insertNukeButtonCallback);
mutationObserver.observe(mutationObserverTargetNode, observerOptions);
// Source: https://github.com/drewminns/slackdeletron/issues/36#issuecomment-395613555
function delFile() {
// first check if we need to do another search
var list = document.getElementsByTagName('h2')
for (var i = 0; i < list.length; i++) {
if (list[i] && list[i].innerText && list[i].innerText == 'Zap! Deleted!') {
document.getElementsByClassName('Button Button__Large')[0].click()
}
}
// look for a delete button
var button = document.getElementsByClassName('File__Button')[0]
if (button) {
button.click()
}
else {
clearTimeout(timeoutStorageVar);
return;
}
var interval = 1000 + (Math.random() * 2000)
timeoutStorageVar = setTimeout(delFile, interval)
}
})();
@boisei0
Copy link
Author

boisei0 commented Dec 1, 2018

Usage:

  1. Install tampermonkey
  2. Install this script
  3. Log in to slackdeletron
  4. Do a search
  5. Press the "Nuke all files" button and watch the files die

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment