User:Yair rand/catfix.js
Note – after saving, you may have to bypass your browser’s cache to see the changes.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
$(document).ready(function($){
var s, c;
if( wgNamespaceNumber === 14 && ( s = document.getElementById("catfix") ) ) {
c = "#" + s.className.split("CATFIX-")[1].replace(/ /g, "_" );
s = s.getElementsByTagName("*")[0] || document.createElement("span");
$("#mw-pages>.mw-content-ltr").find("li>a").each(function(){
var li = this.parentNode, clone = s.cloneNode( false );
li.removeChild( this );
this.setAttribute("href", this.getAttribute("href", 2) + c );
clone.appendChild( this );
li.appendChild( clone );
})
}
})