Last active
January 7, 2016 19:40
-
-
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.
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 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