User:Subfader/ .

I have the following Gadget. It displays an icon on top if you're on a category page. Now I only want it to be displayed if the viewed category page is in the subcategory "Artist".

if( (wgNamespaceNumber == 14) ( && wgTitle != 'Unknown Artist' ) addOnloadHook(function { var strT=wgTitle; var wgTitleF1 = strT.replace(/ - /g, "-"); var wgTitleF2 = wgTitleF1.replace(/\(/g, "-"); var wgTitleF3 = wgTitleF2.replace(/\)/g, "-"); var wgTitleF4 = wgTitleF3.replace(/\./g, "-"); var wgTitleF5 = wgTitleF4.replace(/-/g, " "); var wgTitleF = wgTitleF5.replace(/\  /g, " "); var url= 'http://www.discogs.com/search?type=artists&q=' + encodeURIComponent(wgTitleF) + '&btn=Search'; var fh = getElementsByClassName(document,'h1','firstHeading')[0]; var link = document.createElement('a'); link.style.padding = '0px 6px 1px 4px'; link.href = url; var img = document.createElement('img'); img.src = 'http://mixesdb.com/db/Discogs.png'; link.appendChild(img); link.style.cssFloat = 'right'; link.target = "_blank"; fh.insertBefore(link,fh.childNodes[0]); }) && wgTitle != 'Unknown Artist' ensures teh icon is not displayed on the cat page "Unknown Artist"

I think the  is good so the subcat "Artist" check isn't run on articles and other namespaces. I just duuno how to continue the check against "Category:Artist". If you remember the article icon "SubFader skin"; it did sth similar

I asked on the IRC chan and brion gave me the advice to check against the 'page' > 'page_id' (which is 1052 btw):

there should be an id or something on the category links box, so not that difficult in theory to go trawling through its contents looking for links with a certain name ok, let's assume you're on some category page pull up document.getElementById('catlinks') go through its various child descendents looking for links check them for the desired parent category alternatively, make a JSON call to the web service API [which might be more future-proof and reliable, versus screen-scraping :D]