Very cool stuff! I'm going to be using it personally. Thanks for the hack!
If there will be another version, here's what I hope will be in there (minor things, not really necessary):
- Layout of + and - votes looks more like the layout of what's shown to 1000+ rep members (slight css change)
Layout of + and - votes looks more like the layout of what's shown to 1000+ rep members (slight css change) - Making this into a Firefox plugin or a Chrome extension so it does it automatically (not sure about Firefox plugins, but with Chrome extensions, it's a piece of cake.)
- As this uses jQuery anyway, once the function is executed, the up/down vote counts are loaded into the background and click handlers are added to the total vote counts, so that it really resembles the experience that 1000+ rep users have.
As it's under WTFPL, I'll try to implement those features myself and post my results.
Thanks again!
UPDATE: I started making a Greasemonkey version of this; here's what I have so far (I don't have too much experience with GM, so I'm not sure whether this code will work):
// ==UserScript==
// @name SOUpDownVoteDisplay
// @namespace stackoverflow
// @description Uses API functions to display up and down vote tallies for questions and answers even when users have less than 1000 reputation.
// @include http://*.stackoverflow.com/questions/*
// @include http://*.serverfault.com/questions/*
// @include http://*.superuser.com/questions/*
// @include http://*.meta.stackoverflow.com/questions/*
// @include http://*.stackapps.com/questions/*
// ==/UserScript==
addEventListener("load",function()
{
(function(){w=function(t,q){l='_vote_count';h='up'+l;j='down'+l;k='</div>';s='<div style="color:';$(t).html(s+'green">'+(q[h]?'+':'')+q[h]+k+'<div class="vote-count-separator">'+k+s+'maroon">'+(q[j]==0?'':'-')+q[j]+k)};a='jsonp';c=' .vote-count-post';$.ajax({url:document.location.href.replace(/(http:\/\/)(.*)(\/questions\/.*)\/.*/,'$1api.$2/0.8$3'),dataType:a,jsonp:a,success:function(x){b=x.questions[0];w('#question'+c,b);$.each(b.answers,function(z,y){w('#answer-'+y.answer_id+c,y)})}})})()
},false);
if(navigator.userAgent.indexOf("Chrome")!=-1)
{
var e=document.createEvent("Event");
e.initEvent("load",false,false);
dispatchEvent(e);
}