User:Msh210/blocklinks.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

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.

//Seems good for FF; not tested elsewhere.
//Many thanks to Splarka for help with this script.
function loglink() {//link from special:block to log page
 var t=document.getElementById('mw-bi-target');
 if (!t) return;
 var u=t.getAttribute('value');
 if (!u || u=='') return;
 a=document.createElement('a');
 l="/wiki/Special:Log?user="+u;
 a.setAttribute('href',l);
 x='Logs for '+u;
 a.appendChild(document.createTextNode(x));
 p=getElementsByClassName(document,'p','mw-ipb-conveniencelinks');
 if (p.length!=1) {//just in case they change the name or something
  t.parentNode.insertBefore(a,t)
 } else {
  s=document.createTextNode(' | ');
  o=p[0].childNodes[0];
  p[0].insertBefore(s,o);
  o=p[0].childNodes[0];//s
  p[0].insertBefore(a,o);
 }//end else
}
if (wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == 'Block') addOnloadHook(loglink);