User:Y2K/monobook.js

From Homestar Runner Wiki

(Difference between revisions)
Jump to: navigation, search

Revision as of 06:29, 23 August 2006

// ==UserScript==
// @name          Y2K's Monobook JS
// @namespace     http://fanstuff.hrwiki.org/
// @include       http://hrwiki.org/*
// @include       http://www.hrwiki.org/*
// @include       http://fanstuff.hrwiki.org/*
// ==/UserScript==
// The code above is for if you wanna install this as a Greasemonkey user script.
// NOTE: If you install this as a user script, the time will never "finish loading".

function addQuickbarLink(href, title, before, tooltip)
{
  var li = document.createElement('li');
  var a = document.createElement('a');
  a.appendChild(document.createTextNode(title));
  a.href = href;
  a.title = tooltip;
  li.appendChild(a);
  if (!before)
  {
    document.getElementById('pt-logout').parentNode.appendChild(li);
  }
  else
  {
    before = document.getElementById('pt-'+before);
    before.parentNode.insertBefore(li, before);
  }
}
function addLinks()
{
  addQuickbarLink("/index.php/User:Y2K/monobook.js", "my js", "preferences", "My custom MonoBook JavaScript");
  addQuickbarLink("/index.php/User:Y2K/monobook.css", "my css", "preferences", "My custom Monobook CSS");
  addQuickbarLink("http://fanstuff.hrwiki.org/index.php/User:Y2K/IRC", "my irc toolkit", "preferences", "My toolbox for IRC emulators");
  addQuickbarLink("http://fanstuff.hrwiki.org/index.php/User_talk:Y2K#.2Fjoin_.23virus-irc", "#virus-irc", "preferences", "My IRC emulator");
  addQuickbarLink("http://fanstuff.hrwiki.org/index.php/What's Her Face Answering Machine", "whf answering machine", "preferences", "What's Her Face Answering Machine");
  addQuickbarLink("/index.php/User:Y2K/sig", "my sig", "preferences", "My signature");
}
if (window.addEventListener) window.addEventListener('load', addLinks, false);
else if (window.attachEvent) window.attachEvent('onload', addLinks);

// Add Sydney time just below the "personal menu" list at the top of the page.
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay, modified again by User:Y2K to show Sydney time
//
function getTime() {
  var time = new Date();
  var hours = time.getUTCHours();
  if (hours < 14) { hours = 10 + hours; }
  else if (hours > 13)
  {
    hours = hours - 14
    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);
}
function makeTime() {
  var div = document.createElement( 'div' );
  div.id = 'pt-time';
  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( '10:00:00' ) );
  div.appendChild( mySpan );
  document.getElementById( 'globalWrapper' ).parentNode.appendChild( div );
  doTime = window.setTimeout("getTime()", 1000);
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);

// Adds a purge tab. Found this on Lapper's JS.
function addPurgeButton()
{
  var href = document.location.href;
  {
    var historyHref = document.getElementById( "ca-history" ).firstChild.href;
    var div = document.getElementById( "p-cactions" );
    var ul = div.getElementsByTagName( "ul" )[0];
    var newLi = document.createElement( "li" );
    var newA = document.createElement( "a" );
    newA.setAttribute( "href" , historyHref.replace( "=history" , "=purge" ) );
    var text = document.createTextNode( "purge" );
    newA.appendChild( text );
    newLi.appendChild( newA );
    ul.appendChild( newLi );
  }
}
if ( window.addEventListener ) window.addEventListener( "load" , addPurgeButton , false );
else if ( window.attachEvent ) window.attachEvent( "onload", addPurgeButton );

// include comfortable javascript editor by [[wikipedia:User:Cacycle]]


// levels of undo (each level holds the whole text)
undoBufferMax = 20;


// style for preview box
stylePreviewBox = 'background-color: #f9f9f9;';


// style for custom edit buttons
styleButtons = 'font-size: smaller; padding-left: 0.1em; padding-right: 0.1em';


// presets for input field dropdown options
findHistoryLength = 10;


// preset for combo box select options
presetOptions = [];
presetOptions['summary'] = [


 'Copyedit',
 'Linkfix',
 'Reverting vandalism',
 'Formatting source text'



];


// expiration time span for history cookies in seconds
cookieExpireSec = (365 * 24 * 60 * 60);


// enable cursor horizontal position memory
cursorMemory = true;


// show at least this number of lines ahead of cursor movement
scrollMargin = 1;


// show at least this number of lines ahead of cursor movement for
findMargin = 2;


// find ahead checkbox selected by default
findAheadSelected = true;


// css for change indicators
styleDelete = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #990033;';
styleInsert = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #009933;';
styleMoved  = 'font-weight: bold; vertical-align: text-bottom; font-size: xx-small; padding: 0; border: solid 1px;';
styleBlock  = [


       'background-color: #ffff44;',
       'background-color: #b0ff90;',
       'background-color: #ffcc99;',
       'background-color: #99ffff;',
       'background-color: #99ccff;',
       'background-color: #cc99ff;',
       'background-color: #ff99cc;',
       'background-color: #ffd040;',
       'background-color: #d0d0d0;'



];


// html for change indicators, {number} is replaced by the block number, {block} is replaced by the block style
htmlMovedRight  = '<input type="button" value=">" style="' + styleMoved + ' {block}">';
htmlMovedLeft   = '<input type="button" value="<" style="' + styleMoved + ' {block}">';


htmlBlockStart  = '<span style="{block}">';
htmlBlockEnd    = '</span>';


htmlDeleteStart = '<span style="' + styleDelete + '">';
htmlDeleteEnd   = '</span>';


htmlInsertStart = '<span style="' + styleInsert + '">';
htmlInsertEnd   = '</span>';


// minimal number of real words for a moved block (0 for always displaying block move indicators)
blockMinLength = 3;


// exclude identical sequence starts and endings from change marking
wordDiff = true;


// enable recursive diff to resolve problematic sequences
recursiveDiff = true;


// enable block move display
showBlockMoves = true;

// Installation code for editor removed as I have it running on Greasemonkey
Personal tools