User:Animum/monobook.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, 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: Press Ctrl-F5.
document.write('<script type="text/css"' 
      + 'src="http://en.wikipedia.org/w/index.php?title=Wikipedia:WikiProject_User_scripts/Scripts/Add_LI_menu/css' 
      + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Animum/liveclock.js'
      + '&action=raw&ctype=text/javascript');

mw.loader.load('https://meta.wikimedia.org/w/index.php?title=User:Animum/simpleRevert.js' 
             + '&action=raw&ctype=text/javascript');

function PortletMenu( id ) // Taken from [[w:User:KnowledgeOfSelf/monobook-normal.js]]
 {
 this.menu = document.getElementById( id );
 this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc.
 
 var LIs = this.list.getElementsByTagName( 'li' );
 
 for ( var i = 0; i < LIs.length; i++ )
 {
 this[ LIs[ i ].id ] = LIs[ i ];
 }
 
 this.newItem = function( id, txt, url )
 { var li = document.createElement( 'li' ); li.id   = id;
 var  a = document.createElement( 'a'  );  a.href = url;
 
  a.appendChild( document.createTextNode( txt ) );
 li.appendChild( a );
 
 this[ id ] = li; // watch this!!!
 
 return li;
 }
 
 this.append = function( id, txt, url )
 { this.list.appendChild( this.newItem( id, txt, url ) );
 }
 
 this.insertBefore = function( old, id, txt, url )
 { this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] );
 }
 
 this.getText = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
 this.setText = function( id, txt ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }
 
 this.getHref = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href       }
 this.setHref = function( id, url ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
 
 }
 
$(function() {
  usermenu = new PortletMenu('p-personal');
    document.getElementById('p-personal').getElementsByTagName('ul')[0].style.textTransform = 'none';
    usermenu.setText('pt-mytalk', 'talk');
    usermenu.setText('pt-preferences', 'preferences');
    usermenu.setText('pt-watchlist', 'watchlist');
    usermenu.setText('pt-mycontris', 'contribs');
    usermenu.setText('pt-logout', 'logout');
});