User:Linuxerist~commonswiki/monobook.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
$(function () {
    var tabs = document.getElementById('p-cactions').cloneNode(true);
    tabs.id = 'mytabs';
    var listitems = tabs.getElementsByTagName('LI');
    for (i=0;i<listitems.length;i++) {
        if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
    }

    content = document.getElementById("content");    // Find the content div
    content.parentNode.insertBefore(tabs, content.nextSibling);    // Place tab list right after content div
});

// This script adds "Google search" and "Yahoo! search" links to the toolbox.  Requires [[Wikipedia:WikiProject User scripts/Scripts/addLink]]. <pre><nowiki>

$(function () {  // add onload handler using code from wikibits.js
    var title;
    if (!(title = document.getElementById('t-whatlinkshere') )) return;
    if (!(title = title.getElementsByTagName('a')[0] )) return;
    if (!(title = title.href )) return;
    if (!(title = title.replace(/^.*\/wiki\/Special:Whatlinkshere\//, '') )) return;
    if (!(title = title.replace(/^(Talk|User|Wikipedia|Image|MediaWiki|Template|Help|Category|Portal)(_talk)?:/, '') )) return;
    if (!(title = title.replace(/("|%22)/g, '') )) return;
    if (!(title = title.replace(/_/g, '%20') )) return;
 
    addLink('p-tb', 'http://www.google.com/search?q=%22'+title+'%22%20-Wikipedia&ie=utf-8&oe=utf-8',
            'Google search', 't-googlesearch', 'Search Google for "'+decodeURIComponent(title)+'"', 'G', null);
    addLink('p-tb', 'http://search.yahoo.com/search?p=%22'+title+'%22%20-Wikipedia&ei=UTF-8',
            'Yahoo! search', 't-yahoosearch', 'Search Yahoo! for "'+decodeURIComponent(title)+'"', 'Y', null);
});

// </nowiki></pre>


// <pre><nowiki>

function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
	tabs.insertBefore(li,document.getElementById(after));
    } else {
	tabs.appendChild(li);
    }
    if(id) {
	if(key && title) { ta[id] = [key, title]; }
	else if(key) { ta[id] = [key, '']; }
	else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}
    
// </nowiki></pre>


//<pre><nowiki>
  //  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);
}

$( 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);
}
//</nowiki></pre>


// [[User:Lupin/popups.js]]

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');<noinclude>
Template is for easy pasting of [[Wikipedia:Tools/Navigation popups]] code -- use // [[:en:MediaWiki:Gadget-popups.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); in your [http://en.wikipedia.org/wiki/User:USERNAME/monobook.js monobook.js] (or whatever skin used).</noinclude>