Skip to content

Instantly share code, notes, and snippets.

@mogsdad mogsdad/Roomba-VTZ.user.js
Last active Sep 25, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.