Created
August 25, 2013 12:32
-
-
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.
This file contains hidden or 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
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