User:The Goblin/monobook.js

From Homestar Runner Wiki

< User:The Goblin
Revision as of 05:44, 31 August 2007 by The Goblin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
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.
if ( wgAction == "edit" || wgAction == "submit" ) addOnloadHook ( init_linkfixr ) ;

function init_linkfixr () {
  var tools = document.getElementById("p-tb") ;
  var out = '<li id="t-permalink">' ;

  var ot = document.editform.wpTextbox1.value ;
  var t = get_linkfixr_text ( ot ) ;
  if ( t != ot ) {
    out += "<a href='javascript:run_linkfixr();'>LinkFixr</a>" ;
  } else {
    out += "<span style='color:#888888'>LinkFixr</span>" ;
  }
  tools = tools.getElementsByTagName("ul")[0] ;
  tools.innerHTML += out ;
}

function get_linkfixr_text ( ot ) {
  var t = ot ;

  var ct ;
  do {
    ct = t ;
    t = t.split('[["').join('"[[') ;
    t = t.split('"]]').join(']]"') ;

    t = t.split("[['").join("'[[") ;
    t = t.split("']]").join("]]'") ;

    t = t.split(',]]').join(']],') ;
    t = t.split(':]]').join(']]:') ;
    t = t.split(';]]').join(']];') ;

  } while ( ct != t ) ;

  return t ;
}

function run_linkfixr () {
  var ot = document.editform.wpTextbox1.value ;
  var t = get_linkfixr_text ( ot ) ;
  if ( t != ot ) {
    document.editform.wpTextbox1.value = t ;
    var s = document.editform.wpSummary.value ;
    if ( s != "" ) s += "; " ;
    s += "fixed link(s) using [[MediaWiki:LinkFixr.js]]" ;
    document.editform.wpSummary.value = s ;
  }
}
Personal tools