Skip to content

Instantly share code, notes, and snippets.

@mogsdad
Last active January 7, 2016 19:40
Show Gist options
  • Save mogsdad/767f8adc04d1d5c732c9 to your computer and use it in GitHub Desktop.
Save mogsdad/767f8adc04d1d5c732c9 to your computer and use it in GitHub Desktop.
Display a notice at top of questions, showing whether you've already close-voted.
// ==UserScript==
// @name Close Vote Reminder
// @namespace http://thisisnotafish.net/
// @version 0.1
// @description Display a notice at top of questions, showing whether you've already close-voted.
// @author Mogsdad
// @match http*://stackoverflow.com/questions/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
(function(){
var headerWidth = $('#header').width();
var logoWidth = $('#hlogo').width();
var navWidth = $('#hmenus').width();
var availableWidth = headerWidth - (logoWidth + navWidth);
var noticeHolder = $('<div/>').css({'position':'absolute','left':logoWidth + 'px','font-size':'2em','font-weight':'bold','line-height':'75px','width':availableWidth + 'px','text-align':'center'});
$('#hmenus').before(noticeHolder);
$(document).ajaxComplete(function() {
var alreadyvoted = $( ".close-question-link[title^='You voted']" );
console.log( alreadyvoted.length );
if (alreadyvoted.length) {
noticeHolder.html(alreadyvoted.length ? '<span style="color:maroon">Previously voted.</span>' : '<span style="color:green">Please vote!</span>');
//alert( 'You already voted.' );
}
});
//<a href="#" class="close-question-link" title="You voted to close as 'too broad'. 2 more votes from other users are needed to close this question." data-questionid="34221041" data-isclosed="false">close <span class="existing-flag-count">3</span></a>
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment