Skip to content

Instantly share code, notes, and snippets.

@mogsdad
Last active January 7, 2016 19:40

Revisions

  1. mogsdad revised this gist Jan 7, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @version 0.2
    // @description Display a notice at top of questions with their status wrt close votes.
    // @author Mogsdad
    // @include /^https?:\/\/\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com\/(questions|posts|review)\/\d+/*
    // @include /^https?:\/\/\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com\/(questions|posts|review)\/\d+\/.*/
    // @grant none
    // ==/UserScript==
    /* jshint -W097 */
    @@ -15,7 +15,6 @@
    var logoWidth = $('#hlogo').width();
    var navWidth = $('#hmenus').width();
    var availableWidth = headerWidth - (logoWidth + navWidth);
    console.log('hi');

    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);
  2. mogsdad revised this gist Jan 7, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @version 0.2
    // @description Display a notice at top of questions with their status wrt close votes.
    // @author Mogsdad
    // @include /^https?:\/\/\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com\/(questions|posts|review)/\d+/*
    // @include /^https?:\/\/\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com\/(questions|posts|review)\/\d+/*
    // @grant none
    // ==/UserScript==
    /* jshint -W097 */
  3. mogsdad revised this gist Jan 7, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @version 0.2
    // @description Display a notice at top of questions with their status wrt close votes.
    // @author Mogsdad
    // @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/\d+/*
    // @include /^https?:\/\/\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com\/(questions|posts|review)/\d+/*
    // @grant none
    // ==/UserScript==
    /* jshint -W097 */
    @@ -15,6 +15,7 @@
    var logoWidth = $('#hlogo').width();
    var navWidth = $('#hmenus').width();
    var availableWidth = headerWidth - (logoWidth + navWidth);
    console.log('hi');

    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);
  4. mogsdad revised this gist Jan 4, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -40,12 +40,12 @@
    msg = '<span style="color:green">Needs __more__</span>'
    .replace("__more__",needsN);
    }
    else if ($( ".question-status:contains('closed'),.question-status:contains('put on hold')" ).length) {
    msg = '<span style="color:maroon">Question closed.</span>';
    }
    else if ($( ".question-status:contains('deleted')" ).length) {
    msg = '<span style="color:maroon">Question deleted.</span>';
    }
    else if ($( ".question-status:contains('closed'),.question-status:contains('put on hold')" ).length) {
    msg = '<span style="color:maroon">Question closed.</span>';
    }
    else {
    //msg = '<span style="color:green">Nevermind</span>';
    }
  5. mogsdad revised this gist Jan 2, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,8 @@
    }
    else if ($( ".close-question-link[title~='more']" ).length) {
    var needsN = $( ".close-question-link" ).attr("title").match(/[\d]+ more/i);
    msg = '<span style="color:green">Needs '+needsN+'</span>';
    msg = '<span style="color:green">Needs __more__</span>'
    .replace("__more__",needsN);
    }
    else if ($( ".question-status:contains('closed'),.question-status:contains('put on hold')" ).length) {
    msg = '<span style="color:maroon">Question closed.</span>';
  6. mogsdad revised this gist Jan 2, 2016. 1 changed file with 17 additions and 6 deletions.
    23 changes: 17 additions & 6 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // @name Close Vote Reminder
    // @namespace https://gist.github.com/mogsdad/767f8adc04d1d5c732c9
    // @version 0.2
    // @description Display a notice at top of questions, showing whether you've already close-voted.
    // @description Display a notice at top of questions with their status wrt close votes.
    // @author Mogsdad
    // @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/\d+/*
    // @grant none
    @@ -18,16 +18,26 @@

    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).ready(function(){
    updateNotice();
    });

    $(document).ajaxComplete(function () {
    updateNotice();
    });

    //$(document).ajaxComplete(function() {
    $(document).ready(function() {
    function updateNotice() {
    var msg = "";
    if ($( ".close-question-link[title^='You voted']" ).length) {
    msg = '<span style="color:maroon">Previously voted.</span>';
    var needsN = $( ".close-question-link" ).attr("title").match(/[\d]+ more/i);
    msg = '<span style="color:maroon">You voted. (__more__)</span>'
    .replace("__more__",needsN);
    }
    else if ($( ".close-question-link[title~='more']" ).length) {
    var needsN = $( ".close-question-link" ).attr("title").match(/[\d]+.*votes?/i);
    msg = '<span style="color:green">'+needsN+'</span>';
    var needsN = $( ".close-question-link" ).attr("title").match(/[\d]+ more/i);
    msg = '<span style="color:green">Needs '+needsN+'</span>';
    }
    else if ($( ".question-status:contains('closed'),.question-status:contains('put on hold')" ).length) {
    msg = '<span style="color:maroon">Question closed.</span>';
    @@ -39,5 +49,6 @@
    //msg = '<span style="color:green">Nevermind</span>';
    }
    noticeHolder.html( msg );
    });
    }

    })();
  7. mogsdad revised this gist Jan 2, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name Close Vote Reminder
    // @namespace http://thisisnotafish.net/
    // @namespace https://gist.github.com/mogsdad/767f8adc04d1d5c732c9
    // @version 0.2
    // @description Display a notice at top of questions, showing whether you've already close-voted.
    // @author Mogsdad
  8. mogsdad revised this gist Jan 2, 2016. 1 changed file with 11 additions and 8 deletions.
    19 changes: 11 additions & 8 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Close Vote Reminder
    // @namespace http://thisisnotafish.net/
    // @version 0.1
    // @version 0.2
    // @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)/\d+/*
    @@ -22,18 +22,21 @@
    //$(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) {
    if ($( ".close-question-link[title^='You voted']" ).length) {
    msg = '<span style="color:maroon">Previously voted.</span>';
    }
    else if (closed.length) {
    else if ($( ".close-question-link[title~='more']" ).length) {
    var needsN = $( ".close-question-link" ).attr("title").match(/[\d]+.*votes?/i);
    msg = '<span style="color:green">'+needsN+'</span>';
    }
    else if ($( ".question-status:contains('closed'),.question-status:contains('put on hold')" ).length) {
    msg = '<span style="color:maroon">Question closed.</span>';
    }
    else if ($( ".question-status:contains('deleted')" ).length) {
    msg = '<span style="color:maroon">Question deleted.</span>';
    }
    else {
    msg = '<span style="color:green">Please vote!</span>';
    //msg = '<span style="color:green">Nevermind</span>';
    }
    noticeHolder.html( msg );
    });
  9. mogsdad revised this gist Jan 1, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    // ==UserScript==
    // @name Close Vote Reminder
    // @namespace https://gist.github.com/mogsdad/767f8adc04d1d5c732c9
    // @version 1.0
    // @namespace http://thisisnotafish.net/
    // @version 0.1
    // @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)/*
    // @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/\d+/*
    // @grant none
    // ==/UserScript==
    /* jshint -W097 */
  10. mogsdad revised this gist Jan 1, 2016. 1 changed file with 18 additions and 9 deletions.
    27 changes: 18 additions & 9 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    // ==UserScript==
    // @name Close Vote Reminder
    // @namespace http://thisisnotafish.net/
    // @version 0.1
    // @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
    // @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/*
    // @grant none
    // ==/UserScript==
    /* jshint -W097 */
    'use strict';
    @@ -18,14 +19,22 @@
    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).ajaxComplete(function() {
    $(document).ready(function() {
    var msg = "";
    var alreadyvoted = $( ".close-question-link[title^='You voted']" );
    console.log( alreadyvoted.length );
    //console.log( "alreadyvoted:"+alreadyvoted.length );
    var closed = $( ".question-status:contains('put on hold')" );
    //console.log( "closed:"+closed.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.' );
    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 );
    });

    //<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>
    })();
  11. mogsdad revised this gist Dec 31, 2015. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,7 @@
    // @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
    // @include /^https?://\w*.?(stackoverflow|stackexchange|serverfault|superuser|askubuntu|stackapps)\.com/(questions|posts|review)/*// @grant none
    // ==/UserScript==
    /* jshint -W097 */
    'use strict';
  12. mogsdad created this gist Dec 31, 2015.
    32 changes: 32 additions & 0 deletions CVReminder.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    // ==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>
    })();