Skip to content

Instantly share code, notes, and snippets.

@AmarPrabhu
Created August 25, 2013 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmarPrabhu/6333638 to your computer and use it in GitHub Desktop.
Save AmarPrabhu/6333638 to your computer and use it in GitHub Desktop.
Scroll long pages on quora.com automatically and calculate Q Index of a user.
function pageScroll()
{
window.scrollBy(0,100);//based on bandwidth, decrease for slower speeds
if(($(window).scrollTop() >= $(document).height() - $(window).height() - 200) )
{
if(($(window).scrollTop() >= $(document).height() - $(window).height()))
{
counter++;
if(counter >200)//increase if no of answers is huge
{
alert("in");
clearInterval(scrolldelay);
var qindex = $('.voter_count').map(mapElems).toArray().sort(sortNumber).reduce(reduceQIndex,1);
alert(qindex);
}
else
{
$('div[id*="_more"]').click();
scrolldelay = setTimeout('pageScroll()',100);
}
}
else
{
$('div[id*="_more"]').click();
scrolldelay = setTimeout('pageScroll()',100);
}
}
else
{
scrolldelay = setTimeout('pageScroll()',100);
}
}
var counter = 0;
pageScroll();
function mapElems(index){return parseInt($(this).text())}
function sortNumber(a,b){return b - a}
function reduceQIndex(p,c,i,a){j = i+1;if (j > c){return p}else{return j}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment