-
-
Save rlemon/e2ff662e4731ecf81a95 to your computer and use it in GitHub Desktop.
bulk trash
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
// ==UserScript== | |
// @name BULK TRASH | |
// @author Robert Lemon | |
// @version 1.0 | |
// @namespace | |
// @description Adds a bulk trash button to the chat. | |
// @include http://chat.stackoverflow.com/rooms/* | |
// ==/UserScript== | |
function exec(fn) { | |
var script = document.createElement('script'); | |
script.setAttribute("type", "application/javascript"); | |
script.textContent = '(' + fn + ')();'; | |
document.body.appendChild(script); // run the script | |
} | |
exec(function() { | |
var btn = $('<button class="button">Bulk Trash</button>'), | |
room = document.forms[0].elements.room.value; | |
btn.on('click', function() { | |
var modal = $('<div><h4>Trash Who?</h4></div>'), | |
$users = $('#present-users:not(.more)').clone(); | |
modal.append($users).addClass('popup room-popup').css({ | |
bottom: btn.position().top, | |
left: btn.position().left | |
}).on('click', function(e) { | |
if (confirm("Would you like to trash all posts by " + e.target.title)) { | |
var id = $(e.target).closest('li').prop('id').split('-')[2], | |
all = []; | |
$('.user-' + id + '.monologue .message').each(function() { | |
all.push(this.id.split('-')[1]); | |
}); | |
$.post("/admin/movePosts/" + room, fkey({ | |
ids: all.join(','), | |
to: 23262 | |
})); | |
modal.remove(); | |
} | |
return false; | |
}); | |
$(document.body).append(modal); | |
return false; | |
}); | |
$('#chat-buttons').append(btn); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment