Large

Stack Exchange: "View Vote totals" without 1k rep

By Rob W Last update Dec 12, 2012 — Installed 853 times.

Script Summary: Enables the "View vote counts" feature on the Stack Exchange websites, without requiring any reputation or an account.



Version: 1.5.2

Script homepage

Vote counts on the Stack Exchange

The vote counts are a great tool to determine whether an answer on one of the Stack Exchange (SE) websites is useful (disputed) or not. Unfortunately, not many of us have enough time to join all of the SE websites and get 1000 reputation.

This script (and Chrome extension in the Chrome Web Store) adds the View Vote counts feature to each SE site. If you've already sufficient reputation to view the Vote counts, the script does not affect that particular site.

Screenshot



Browser compatibility

The code has successfully been tested in the following browsers:

  • Firefox 3.0 - 16a
  • Opera 9.00 - 12.00
  • Chrome 1 - 23
  • Internet Explorer 7 - 10
  • Safari 3.2.3 - 5.1.7

Change log

  • 6 February 2012 - 1.0 - Release
  • 7 February 2012 - 1.1 - Fixed layout for IE 7-.
  • 7 February 2012 - 1.2 - Fix: Enables showing view counts after voting.
  • 13 June 2012 - 1.3 - Upgraded to the Stack Exchange 2.0 API
  • 10 November 2012 - 1.3 - Uploaded Chrome extension
  • 16 November 2012 - 1.4 - Added support for /review/
  • 16 November 2012 - 1.5 - Added support for /review/ (Suggested edits)
  • 19 November 2012 - 1.5.1 - Corrected one-letter typo.

Bookmarklet (1838 bytes)

The code below is the short version of the code. Its size is only 1838 bytes and supported by all listed browsers.

javascript:void function(a){var h=a.head||a.getElementsByTagName("head")[0]||a.documentElement,e=a.createElement("style");h.appendChild(e);e.styleSheet?e.styleSheet.cssText="/*Added through UserScript*/.vote-count-post{cursor:pointer;}.vote-count-post[title]{cursor:default;}.vote-count-separator{height:0;*margin-left:0;}":e.appendChild(a.createTextNode("/*Added through UserScript*/.vote-count-post{cursor:pointer;}.vote-count-post[title]{cursor:default;}.vote-count-separator{height:0;*margin-left:0;}"));var i="?filter=!)q3b*aB43Xc&key=DwnkTjZvdT0qLs*o8rNDWw((&site="+location.host,f=1,g=StackExchange.helpers,j=$.fn.click;$.fn.click=function(a,d){return this.hasClass("vote-count-post")&&!f?this:j.call(this,a,d)};a=function(a){var d=$(this),b=this.title;/up \/ /.test(b)||/View/.test(b)&&f||(f=0,b=d.siblings('input[type="hidden"]').val(),b||(b=d.closest("[data-questionid],[data-answerid]"),b=b.attr("data-answerid")||b.attr("data-questionid")),b?(g.addSpinner(d),$.ajax({type:"GET",url:"http://api.stackexchange.com/2.0/posts/"+b+i+"&callback=?",dataType:"json",success:function(c){var c=c.items[0],a=c.up_vote_count,c=c.down_vote_count,a=a?"+"+a:0,c=c?"-"+c:0;$(".error-notification").fadeOut("fast",function(){$(this).remove()});d.css("cursor","default").attr("title",a+" up / "+c+" down").html('<div style="color:green">'+a+'</div><div class="vote-count-separator"></div><div style="color:maroon">'+c+"</div>")},error:function(a){g.removeSpinner();g.showErrorPopup(d.parent(),a.responseText&&100>a.responseText.length?a.responseText:"An error occurred during vote count fetch")}}),a.stopImmediateProgagation()):console.error("Post ID not found! Please report this at http://stackapps.com/q/3082/9699"))};if($.fn.on)$(document).on("click",".vote-count-post",a);else $(document).delegate(".vote-count-post","click",a)}(document);