User:X-Spider2/monobook.js

From Homestar Runner Wiki

Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Mozilla / Firefox: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac)
  • Safari: press Cmd-Option-E
  • IE: hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Konqueror: simply click the Reload button, or press F5
  • Opera users may need to completely clear their cache in Tools→Preferences.
// ==UserScript==
// @name          x-Spider2's monobook JS
// @namespace     http://www.hrwiki.org/
// @description   The JS currently being used by HRWikian X-Spider2.
// @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)
{
  var li = document.createElement('li');
  var a = document.createElement('a');
  a.appendChild(document.createTextNode(title));
  a.href = href;
  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("javascript:history.back()", "back", "userpage");
  addQuickbarLink("javascript:history.forward()", "forward", "userpage");
  addQuickbarLink("javascript:location.reload()", "refresh", "userpage");
  addQuickbarLink("javascript:window.print()", "print", "userpage");
  addQuickbarLink("http://www.hrwiki.org/index.php/User:X-Spider2/monobook.js", "my js", "preferences");
  addQuickbarLink("http://www.hrwiki.org/index.php/User:X-Spider2/monobook.css", "my css", "preferences");
}
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:X-Spider2 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);

 // 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 );

// Adds bottom tabs
function morelinks() {
  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;
  }
  document.getElementById('column-content').appendChild(tabs);
}
if (window.addEventListener) window.addEventListener("load",morelinks,false);
else if (window.attachEvent) window.attachEvent("onload",morelinks);

// include comfortable javascript editor by 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',
 'Revert to what it was before'



];


// 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;

// Install [[User:X-Spider2/editor.js]] editor code
document.write('<script type="text/javascript" src="' 
 + 'http://www.hrwiki.org/index.php?title=User:X-Spider2/editor.js' 
 + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// Install [[User:X-Spider2/diff.js]] editor code
document.write('<script type="text/javascript" src="' 
 + 'http://www.hrwiki.org/index.php?title=User:X-Spider2/diff.js' 
 + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// Install Live Preview...
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// Now set everything up
window.onload = Main;

function Main()
{
 LivePreviewInstall();
 // You may include here other "extensions"
}

function addbookmark(bookmarkurl,bookmarktitle)
{
if (document.all)
window.external.AddFavorite(".22" + bookmarkurl + ".22",".22" + bookmarktitle + ".22")
}
Personal tools