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 https://gist.github.com/mogsdad/767f8adc04d1d5c732c9 | |
// @version 1.0 | |
// @description Display a notice at top of questions, showing whether you've already close-voted. | |
// @author Mogsdad | |
// @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/* | |
// @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() { | |
$(document).ready(function() { | |
var msg = ""; | |
var alreadyvoted = $( ".close-question-link[title^='You voted']" ); | |
//console.log( "alreadyvoted:"+alreadyvoted.length ); | |
var closed = $( ".question-status:contains('put on hold')" ); | |
//console.log( "closed:"+closed.length ); | |
if (alreadyvoted.length) { | |
msg = '<span style="color:maroon">Previously voted.</span>'; | |
} | |
else if (closed.length) { | |
msg = '<span style="color:maroon">Question closed.</span>'; | |
} | |
else { | |
msg = '<span style="color:green">Please vote!</span>'; | |
} | |
noticeHolder.html( msg ); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment