Skip to content

Instantly share code, notes, and snippets.

@mogsdad
Last active September 25, 2015 02:47
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 mogsdad/ed30af363a376ec4a1c2 to your computer and use it in GitHub Desktop.
Save mogsdad/ed30af363a376ec4a1c2 to your computer and use it in GitHub Desktop.
Presents a set of buttons to quickly down-vote questions & answers for automatic deletion. (AKA Roomba candidates) See documentation:http://stackapps.com/questions/6599/roomba-vtz-vote-to-zero.
// ==UserScript==
// @name Roomba-VTZ (Vote-to-zero)
// @namespace https://gist.github.com/mogsdad/ed30af363a376ec4a1c2
// @version 1.2
// @description Presents a set of buttons to quickly down-vote questions & answers for automatic deletion. (AKA Roomba candidates)
// @author David Bingham (Mogsdad)
// @include /^https?://(meta\.)?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/questions/[0-9]+.*/
// @grant none
// ==/UserScript==
(function () {
// Filter function
// Based on http://stackoverflow.com/a/965962/1677912
$.expr[':'].ancestors = function(a,i,m){
return $(a).closest(m[3]).length < 1;
};
// Only run on closed non-duplicate non-migrated questions with no accepted answer (migrat matches migrated and migration)
if (!($('.question-status').length > 0) ||
$('.question-status').filter(':contains("duplicate"), :contains("migrat")').length > 0 ||
$('.vote-accepted-on').length > 0)
return;
// Check available horizontal width for VtzDiv
var logoRect = document.getElementById('hlogo').getBoundingClientRect();
var navRect = document.getElementById('hmenus').getBoundingClientRect();
var availableWidth = navRect.left - logoRect.right;
$('#hmenus').before($('<div id="VtzDiv" style="position: absolute;left:'+ (logoRect.width + 7.5) +'px;"><table id="VtzTable"><tr id="VtzRow"/></table></div>'));
// Hide VtzDiv to avoid jumping display (not needed, it turns out)
//$('VtzDiv').css({"opacity":"100%"});
$('.vote').filter(':ancestors(.deleted-answer)') // Find votes for question & undeleted answers
.closest('td').clone(true).appendTo("#VtzRow") // Make table of vote cells
.find('[class^="star"],.favoritecount,.vote-accepted-on,.bounty-award').remove(); // without unecessary flair
if ($('#VtzTable').width() > availableWidth) {
// Need to scale the table
$('#VtzDiv').css({'transform-origin':'0% 25%','transform':'scale('+ availableWidth/$('#VtzTable').width() +')'});
}
// Show final table
//$('VtzDiv').css({"opacity":"0%"});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment