User:Haza-w/interiot.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

  //  Add an "Interiot" link to your "personal menu" portlet.
  //  For the Monobook skin, this is at the top-right of the browser window.
  //  This script works in all skins and is compatible with scripts that move the
  //  "p-personal" personal options portlet.
  //
  //  Code by Haza-w based on KATE script
  //
  //  Indicate the node you would like "Interiot" to appear before:
  //    pt-userpage, pt-mytalk, pt-preferences,
  //    pt-watchlist, pt-mycontris, pt-logout
  //
gsInteriotInsertBefore = 'pt-logout'; // leave blank to append after "logout"
  //
function InteriotLink()
{
  var isIE = document.all?1:0,
    user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
 
  var li = document.createElement( 'li' );
    li.id = 'pt-interiot';
 
    var a = document.createElement( 'a' );
      a.appendChild( document.createTextNode( 'Interiot' ) );
      a.href = 'http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?site=en.wikipedia.org&username=' + user;
 
    li.appendChild( a );
 
  var li2 = document.createElement( 'li' );
    li2.id = 'pt-interiot';
 
    var a2 = document.createElement( 'a' );
      a2.appendChild( document.createTextNode( 'Mathbot' ) );
      a2.href = 'http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?lang=en&user=' + user;
 
    li2.appendChild( a2 );
 
  if ( ! gsInteriotInsertBefore ) // append to end (right) of list if not defined
  {
     document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
     document.getElementById( 'pt-logout' ).parentNode.appendChild( li2 );
  }
  else
  {  var before = document.getElementById( gsInteriotInsertBefore );
      before.parentNode.insertBefore( li, before );
      before.parentNode.insertBefore( li2, before );
  }
}
 
if ( window.addEventListener ) window.addEventListener( 'load', InteriotLink, false );
else if ( window.attachEvent      ) window.attachEvent   ( 'onload', InteriotLink );