Created
July 21, 2010 17:14
-
-
Save higeorange/484783 to your computer and use it in GitHub Desktop.
This file contains 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
// ==UserScript== | |
// @include http://delicious.com/tag/* | |
// ==/UserScript== | |
(function(w) { | |
//Settings | |
var POST_COUNT = 100; // 1-100 | |
var THRESHOLD = 2; | |
var $ = function(id) { return $[id] || ( $[id] = document.getElementById(id) )}; | |
var tags = location.href.split("/")[4]; | |
w.listPeople = function(data) { | |
// count | |
var people = {}; | |
var p; | |
for(var i = 0, l = data.length; i < l; i++) { | |
p = data[i]["a"]; | |
if(people[p] >= 1) { | |
people[p]++; | |
} else { | |
people[p] = 1; | |
} | |
} | |
var iul = $("people-list"); | |
iul.innerHTML = ""; | |
var count = 0; | |
for(var t in people) { | |
if(people[t] >= THRESHOLD) { | |
var li = document.createElement("li"); | |
var a = document.createElement("a"); | |
a.className = "addTag"; | |
a.href = "/" + t + "/" + tags; | |
var span = document.createElement("span"); | |
span.innerHTML = t + " : " + people[t]; | |
a.appendChild(span); | |
li.appendChild(a); | |
iul.appendChild(li); | |
count ++; | |
} | |
} | |
$("c").innerHTML = count; | |
} | |
if(tags.split("+").length < 1) return; | |
//make box | |
var h = [ | |
'<div class="sidebar-list toggle on">', | |
'<h3><span class="toggle-button no">People</span><em id="c">NaN</em></h3>', | |
'<ul id="people-list" class="list">', | |
'<li>loading</li>', | |
'</ul>', | |
'</div>' | |
]; | |
$('sidebar').innerHTML += h.join(""); | |
var feed_url = "http://feeds.delicious.com/v2/json/tag/" + tags + "?callback=listPeople&count=" + POST_COUNT | |
//JSONP | |
var script = document.createElement('script'); | |
script.type = "text/javascript"; | |
script.src = feed_url; | |
document.body.appendChild(script); | |
})(this.unsafeWindow || window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment