User:Begoon/myGallery.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Begoon/myGallery. |
/*
myGallery.js
------------
Description: Adds a Tab to the Vector skin providing 1-click access to your own uploaded images,
using http://toolserver.org/~daniel/WikiSense/Gallery.php
Only written/tested for Vector skin.
*/
//function to find first 'ul' node in an element
function getFirstULchild(n)
{
x=n.firstChild;
while (x.tagName != 'UL')
{
x=x.nextSibling;
}
return x;
}
//attach this whole event to Onload for page
addOnloadHook(function () {
// Create a <li> element, and an <a> element, and a <span> element, and set some properties
var liContainer = document.createElement("li");
// build and assign the url for the link
var myLink = document.createElement('a');
myLink.href = 'http://toolserver.org/~daniel/WikiSense/Gallery.php?wikifam=.wiki.x.io';
myLink.href += '&wikilang=en&order=-img_timestamp&img_user_text='
myLink.href += wgUserName; //currently logged in user
myLink.href += '&max=250&ofs=0&max=250';
var mySpan = document.createElement('span');
mySpan.innerHTML = 'My Gallery';
//nest the <span> in the <a>, then the <a> in the <li>
myLink.appendChild(mySpan);
liContainer.appendChild(myLink);
//insert the <li>, now containing both nested elements, into the DOM
//it should be inserted before the watch/unwatch link/icon
y = (document.getElementById("ca-unwatch"));
if (!y)
{
y = (document.getElementById("ca-watch"));
}
if (y)
{
getFirstULchild(document.getElementById("p-views")).insertBefore(liContainer,y);
}
});
/*
END OF: myGallery.js
--------------------
*/