Created
November 28, 2012 01:33
-
-
Save imaginabit/4158476 to your computer and use it in GitHub Desktop.
Show a Tubmlr top rebloged sources of current post
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
/* | |
You can see it in action here : | |
http://takurecortes.tumblr.com/post/36505473972/tumblr-hates-nic | |
just copy this in your tumblr theme html between <script></script> tags or use the raw option to get the file | |
*/ | |
google.load("jquery", "1.3"); | |
google.setOnLoadCallback(function() { | |
jQuery(function($) { | |
$(".notes").after("<div id='takuStats' style='border:1px solid black;background: #ddd;color:#000;padding:1em' >Clickme after load all notes</div>"); | |
$('#takuStats').click(function(){ | |
notas = $(".note").length-1; | |
reblogs = $(".note.reblog").length; | |
likes= $(".note.like").length; | |
var reblogers= new Object(); | |
$.each($(".source_tumblelog"), function(index, value) { | |
if (reblogers[value.innerHTML]===undefined) | |
reblogers[value.innerHTML]=1; | |
else | |
reblogers[value.innerHTML]++ | |
});1 | |
sortable= []; | |
for (var v in reblogers) sortable.push([v, reblogers[v]]); | |
top_reblogs = sortable.sort(function(a, b) {return b[1] - a[1]}); | |
$('#takuStats').html(''); | |
$('#takuStats').append("notes :"+notas+"<br>"); | |
$('#takuStats').append("reblogs :"+reblogs+"<br>"); | |
$('#takuStats').append("likes :"+likes+"<br>"); | |
$('#takuStats').append("Top Reblog sources<br>"); | |
for (var i=0;i<10;i++){ | |
$('#takuStats').append( "<a href='http://"+top_reblogs[i][0]+".tumblr.com'>"+top_reblogs[i][0]+'</a> '+top_reblogs[i][1]+'</br>' ); | |
} | |
}); | |
i = 0; | |
function checkNotes(){ | |
if ($(".more_notes_link").size()>0){ | |
i++; | |
if (i%20!=0){ | |
setTimeout(function() { | |
$(".more_notes_link").click(); | |
checkNotes(); | |
console.log("more notes"); | |
},1003); | |
} else | |
$('#takuStats').click(); | |
} | |
} | |
$(".more_notes_link").click(function(){checkNotes();}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment