User:Nx/Scripts/RandomAny.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
if (typeof randomanyindent == 'undefined') randomanyindent = false;
if (typeof randomanyns == 'undefined') {
// Format is: { <namespacenumber> : [<url escaped namespace name>, <name that appears in toolbar>, <name that appears in tooltip> ] }
randomanyns = { 106 : ['Fun', 'Fun', 'Fun'],
107: ['Fun' , 'Fun', 'Fun'] ,
2 : ['User_talk', 'talk', 'User talk'],
}
}
function randomany() {
if (n_randompage = document.getElementById('n-randompage')) {
if ( typeof randomanyns[wgNamespaceNumber] != 'undefined') {
n_randomany = document.createElement('li');
n_randomany.id = "n-randomany";
n_randomany.innerHTML = "<a"+' href="/wiki/Special:Random/' + randomanyns[wgNamespaceNumber][0] +
'" title="Load a random page from ' + randomanyns[wgNamespaceNumber][2] + ' namespace">' +
'Random ' + randomanyns[wgNamespaceNumber][1] + ' page</a>';
if (randomanyindent) {
n_randomanyul = document.createElement('ul');
n_randomanyul.appendChild(n_randomany);
n_randomany = n_randomanyul;
}
n_randompage.parentNode.insertBefore(n_randomany,n_randompage.nextSibling);
}
}
}
addOnloadHook(randomany)