There are 9 previous versions of this script.
// ==UserScript==
// @name userscripts.org user menu
// @version 2013.0319.1152
// @description Get the user menu back for quick access to scripts, script upload etc. (configurable)
// @namespace http://userscripts.org/scripts/show/104942
// @author Tristan DANIEL (PATATE12 aka. jesus2099/shamo)
// @licence CC BY-NC-SA 3.0 FR (http://creativecommons.org/licenses/by-nc-sa/3.0/fr/)
// @grant none
// @include http://userscripts.org*
// @run-at document-end
// ==/UserScript==
(function(){"use strict";
/* - --- - --- - --- - START OF CONFIGURATION - --- - --- - --- -
hidedelay : number of ms before the menu disappears when mouse quits
clickhidedelay : number of ms before the menu disappears at mouse click (usually less)
menuitems : list your desired menu items here
you can use variables like %username%, %scriptid% %thirduserid%(detected third pardy user)
you can write headers instead of links, with "----"
userNameOrId : used for public profile link instead of home link on your username : "userscripts.org/users/**userNameOrId here**" link.
leave blank and it'll use your displayed name. if not satisfactory, specify here your user id or name */
var hidedelay = 200;
var clickhidedelay = 100;
var menuitems = {
"home": "/home",
"%username%": "----",
"my scripts": "/home/scripts",
"new script (file upload)": "/scripts/new",
"new script (code paste)": "/scripts/new?form=true",
"settings": "/home/settings",
"widgets": "/home/widgets",
"their scripts": "----",
"favourite scripts": "/home/favorites",
"search \"%username%\" in scripts": "/scripts/search?q=%username%",
"community": "----",
"send new message to this user (%thirduserid%)": "/messages/new?user_id=%thirduserid%",
"create new topic on this script (%scriptid%)": "/topics/new?script_id=%scriptid%",
"comments": "/home/comments",
"monitored topics": "/home/posts",
"search \"%username%\" in forums": "/posts/search?kind=forums&q=%username%",
}
var userNameOrId = "";
/* - --- - --- - --- - END OF CONFIGURATION - --- - --- - --- - */
var user = document.querySelectorAll("div#top ul.login_status li");
if (user.length > 2) { user = user[1]; } else { user = null; }
var to;
var usermenu;
var scriptid = self.location.href.match(/\/scripts\/.+\/([0-9]+)$/);
var thirduserid = self.location.href.match(/\/users\/([0-9]+)/);
if (user) {
var ulink = user.getElementsByTagName("a")[0];
ulink.setAttribute("href", "/users/"+(userNameOrId!=""?userNameOrId:ulink.firstChild.nodeValue));
ulink.appendChild(document.createTextNode("+"));
usermenu = document.createElement("ul");
usermenu.setAttribute("id", "usermenu");
usermenu.style.position = "absolute";
usermenu.style.display = "none";
usermenu.style.background = "black";
usermenu.style.listStyleType = "none";
usermenu.style.padding = ".4em 1em";
for (var item in menuitems) {
var contextual = menuitems[item].match(/%(scriptid|thirduserid)%/) || item.match(/%(scriptid|thirduserid)%/);
var contextualok = false;
var link = !menuitems[item].match(/^----$/);
var li = document.createElement("li");
var a = document.createElement(link?"a":"span");
a.style.color = link?"white":"orange";
var txt = item.replace(/%username%/, ulink.firstChild.nodeValue);
var url = menuitems[item].replace(/%username%/, ulink.firstChild.nodeValue);
if (contextual) {
a.style.background = "maroon";
if (scriptid && (menuitems[item].match(/%scriptid%/) || item.match(/%scriptid%/))) {
txt = txt.replace(/%scriptid%/, scriptid[1]);
url = url.replace(/%scriptid%/, scriptid[1]);
contextualok = true;
}
if (thirduserid && (menuitems[item].match(/%thirduserid%/) || item.match(/%thirduserid%/))) {
txt = txt.replace(/%thirduserid%/, thirduserid[1]);
url = url.replace(/%thirduserid%/, thirduserid[1]);
contextualok = true;
}
}
if (link) { a.setAttribute("href", url); }
a.appendChild(document.createTextNode(txt));
li.appendChild(a);
if (!(contextual&&!contextualok)) {usermenu.appendChild(li); }
}
document.body.appendChild(usermenu);
user.addEventListener("mouseover", function(e) {showUserMenu(e, true);}, true);
usermenu.addEventListener("mouseover", function(e) {showUserMenu(e, true);}, true);
user.addEventListener("mouseout", function(e) {showUserMenu(e, false);}, true);
usermenu.addEventListener("mouseout", function(e) {showUserMenu(e, false);}, true);
document.body.addEventListener("click", function(e) {showUserMenu(e, false);}, false);
}
function showUserMenu(e, on) {
if (to) { clearTimeout(to); to = null; }
switch (on) {
case true:
usermenu.style.left = (user.parentNode.parentNode.offsetLeft+800)+"px";
usermenu.style.top = (user.offsetTop+24)+"px";
usermenu.style.display = "block";
break;
case false:
to = setTimeout("var um = document.getElementById(\"usermenu\"); if(um){um.style.display = \"none\";}", (e.type=="click")?clickhidedelay:hidedelay);
if (e.type != "click") {
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
break;
}
}
})();