Jump to content

User:Prof Jolly/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// [[User:Lupin/popups.js]] - please include this line 

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

// Script from [[User:Lupin/recent2.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 //  Add time to your monobook "personal menu" list at the very top of the page.
  //  Created by [[User:Mathwiz2020]]
  //
  //  Indicate where you would like the time to appear:
  //    pt-userpage, pt-mytalk, pt-preferences,
  //    pt-watchlist, pt-mycontris, pt-logout
  //
gsTimeInsertBefore = ''; // leave blank to append after "logout"
  //
function makeTime()
{
  var li = document.createElement( 'li' );
  li.id = 'pt-time';

  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( '00:00:00' ) );

  li.appendChild( mySpan );

  if ( ! gsTimeInsertBefore ) { // append to end (right) of list
    document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
  }
  else { 
    var before = document.getElementById( gsTimeInsertBefore );
    before.appendChild( li, before );
  }
  doTime = window.setTimeout("getTime()", 1000);
}

addOnloadHook( makeTime );

function getTime()
{
  var time = new Date();
  var hours = time.getUTCHours();
  if (hours < 10) { hours = "0" + hours; }
  var minutes = time.getUTCMinutes();
  if (minutes < 10) { minutes = "0" + minutes; }
  var seconds = time.getUTCSeconds();
  if (seconds < 10) { seconds = "0" + seconds; }
  var currentTime = hours + ":" + minutes + ":" + seconds;
  document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime);
  doTime = window.setTimeout("getTime()", 1000);
}
//


addOnloadHook(function () {
    var searchGoButton = document.getElementById('searchGoButton');
    if (!searchGoButton) return;

    var searchNsHidden = document.createElement('input');
    searchNsHidden.id = 'searchNsHidden';
    searchNsHidden.type = 'hidden';
    searchNsHidden.name = 'ns0';
    searchNsHidden.value = '1';

    var searchNsMenu = document.createElement('select');
    searchNsMenu.id = 'searchNsMenu';
    searchNsMenu.name = 'ns';
    searchNsMenu.innerHTML =
        '<option value="0">(Main)</option>\n' +
        '<option value="1">Talk</option>\n' +
        '<option value="2">User</option>\n' +
        '<option value="3">User talk</option>\n' +
        '<option value="4">Wikipedia</option>\n' +
        '<option value="5">Wikipedia talk</option>\n' +
        '<option value="6">Image</option>\n' +
        '<option value="7">Image talk</option>\n' +
        '<option value="8">MediaWiki</option>\n' +
        '<option value="9">MediaWiki talk</option>\n' +
        '<option value="10">Template</option>\n' +
        '<option value="11">Template talk</option>\n' +
        '<option value="12">Help</option>\n' +
        '<option value="13">Help talk</option>\n' +
        '<option value="14">Category</option>\n' +
        '<option value="15">Category talk</option>\n' +
        '<option value="100">Portal</option>\n' +
        '<option value="101">Portal talk</option>\n' ;
    searchNsMenu.onchange = function () {
        searchNsHidden.name = 'ns' + (this.selectedIndex < 0 ? '0' : this.options[this.selectedIndex].value);
    };

    // From /skins-1.5/monobook/main.css?5:
    searchNsMenu.style.width = '10.9em';
    searchNsMenu.style.margin = '0';
    searchNsMenu.style.fontSize = '95%';

    searchGoButton.parentNode.insertBefore(searchNsHidden, searchGoButton);
    searchGoButton.parentNode.insertBefore(searchNsMenu, searchGoButton);
});

//