There are 1 previous version of this script.
// ==UserScript==
// @name Delicious.com - Bundle Names on Hover
// @namespace http://murklins.talkoncorners.net
// @description On the bundle edit pages, hover over a tag to show which bundles it belongs to.
// @include https://secure.delicious.com/settings/tags/bundle/edit*
// ==/UserScript==
// Grab the tag list and initializee the title text with a temp message
var tagDiv = document.getElementById("alphacloud");
var tags = document.evaluate("ul/li/label", tagDiv, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var tagBundles = new Object();
var unfetchedBundles = new Object();
for (var i = 0; i < tags.snapshotLength; i++) {
var label = tags.snapshotItem(i);
label.setAttribute("title", "Getting bundles...");
}
// now do the work
fetchBundles();
function fetchBundles() {
GM_xmlhttpRequest({
method: "GET",
url: "https://secure.delicious.com/settings/tags/bundle",
onload: function(details) {
// get the name and edit link of each bundle
var bundled = "";
var arr;
var bundleRegex = new RegExp("<span>(.*?)</span>\\s*?<a href=\"(/settings/tags/bundle/edit.*?)(bundle=)(.*?)\">Edit</a>","g");
while (arr = bundleRegex.exec(details.responseText)) {
var link = "https://secure.delicious.com" + arr[2] + arr[3] + arr[4];
var name = arr[1];
unfetchedBundles[name] = true;
fetchActiveTags(name, link);
}
}
});
}
function fetchActiveTags(name, link) {
GM_xmlhttpRequest({
method: "GET",
url: link,
onload: function(details) {
// get all the tags that are turned on
var arr, thisBundlesTagsArr;
var thisBundlesTags = "";
var tagRegex = new RegExp("<input type=\"text\" id=\"tagsInput\" name=\"tagsInput\" value=\"(.*?)\">","g");
arr = tagRegex.exec(details.responseText);
if (arr) {
thisBundlesTags = arr[1];
}
if (tags != "") {
thisBundlesTagsArr = thisBundlesTags.split(" ");
}
// assign the current bundle name to each tag found to be in the bundle
for (var i = 0; i < thisBundlesTagsArr.length; i++) {
var tag = thisBundlesTagsArr[i].toLowerCase();
if (tagBundles[tag] == null) {
tagBundles[tag] = new Object();
}
tagBundles[tag][name] = name;
}
// this bundle is done, so set its unfetched flag to false
unfetchedBundles[name] = false;
// now check to see if the entire set of bundles have completed the callback
var done = true;
for (var bname in unfetchedBundles) {
if (unfetchedBundles[bname]) {
done = false;
}
}
// if all the bundles are done, the tags can now be assigned their hover text
if (done) {
for (var i = 0; i < tags.snapshotLength; i++) {
var label = tags.snapshotItem(i);
// the tag name is the id stripped of the "label-" prefix
var t = label.id.substr(6);
if (tagBundles[t] != null) {
var b = [];
for (var bname in tagBundles[t]) {
b[b.length] = bname;
}
b.sort();
b = b.join(", ");
b = b.substring(0, b.length);
label.setAttribute("title", b);
}
else {
label.setAttribute("title", "Unbundled");
}
}
}
}
});
}
