Last active
September 24, 2015 19:46
-
-
Save Tiny-Giant/d8347fa5d5bbaaeb6271 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Roomba-VTZ (Vote-to-zero) | |
| // @namespace https://gist.github.com/mogsdad/ed30af363a376ec4a1c2 | |
| // @version 1.1 | |
| // @description Presents a set of buttons to quickly down-vote questions & answers for automatic deletion. (AKA Roomba candidates) | |
| // @author David Bingham (Mogsdad) | |
| // @include /^https?://\w*.?(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 || | |
| $('.question-status').filter(':contains("duplicate"), :contains("migrat")').length || | |
| $('.vote-accepted-on').length) | |
| return; | |
| // Check available horizontal width for VtzDiv | |
| var headerWidth = $('#header').width(); | |
| var logoWidth = $('#hlogo').width(); | |
| var navWidth = $('#hmenus').width(); | |
| var availableWidth = headerWidth - (logoWidth + navWidth); | |
| $('#hmenus').before($('<div id="VtzDiv" style="visibility: hidden;position: absolute;left:' + ($('#hlogo').width() + 7.5) + 'px"><table id="VtzTable"><tr id="VtzRow"/></table></div>')); | |
| $('.vote').closest('td').filter(':ancestors(.deleted-answer)') // Find votes for question & undeleted answers | |
| .clone(true).css({'padding':0}).appendTo("#VtzRow") // Make table of vote cells | |
| .find('[class^="star"],.favoritecount,.vote-accepted-on,.bounty-award').remove(); // without unecessary flair | |
| if ($('#VtzDiv').width() > availableWidth) { | |
| // Need to scale the table | |
| $('#VtzDiv').css({'transform-origin':'0% 30%','transform':'scale('+ availableWidth/$('#VtzDiv').width() +')'}); | |
| } | |
| $('#VtzDiv').css({"visibility":"visible"}); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment