User:Zocky/monobook.js

From Wikipedia

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); 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.

// [[User:Zocky/foo.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://test.wikipedia.org/w/index.php?title=User:Zocky/foolib.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

document.write('<link rel="stylesheet" type="text/css" href="'  
             + 'http://test.wikipedia.org/w/index.php?title=User:Zocky/foo.css'
             + '&action=raw&ctype=text/css&dontcountme=s">');

addLoadEvent (fooInit);

function fooInit()
{
  if ($('foo-application'))
  {
    $('foo-application').style.display='none';
    insert$('<div style="border:green solid 1px;background:#dfd;margin:1em;padding:1em;" id="foo-run"><center><b>This page contains an embedded application. If you trust the maintainer(s) of the page, you can <a href="javascript:fooRun()">run it</a>.</b></center></div>','top','content');
  }
}

function fooRun()
{
  $('foo-run').style.display="none";
  window['foo']=[];
  foo['autorun']=[];
  foo['xslt']=[];
  fooProcessPage();
}

function fooProcessPage()
{
  var fooTags=x$nodes("//div[contains(@class,'foo-wrapper') and not(@unwrapped='true')]");
  for ( var j=0 ; j < fooTags.snapshotLength; j++ )
  {
    var fooTag=fooTags.snapshotItem(j);
    fooTag.innerHTML=fooTag.innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
    attr$(fooTag,'unwrapped','true');
  }

  var fooTags=x$nodes("//div[contains(@class,'foo-autorun') and not (@unwrapped='true')]");
  for ( var j=0 ; j < fooTags.snapshotLength; j++ )
  {
    try
    {
      var fooTag=fooTags.snapshotItem(j);
      if (!(fooTag.id in foo.autorun))
      {
        var fooText=fooTag.textContent;
        fooTag.innerHTML='<textarea>'+fooText+'</textarea>';
        eval (fooText);
        foo.autorun[fooTag.id]=fooText;
      }
      attr$(fooTag,'unwrapped','true');
    }
    catch (e) {alert ("autorun "+fooTag.id+":\n"+e.message)}
  }

  var fooTags=x$nodes("//div[contains(@class,'foo-xslt')]");
  for ( var j=0 ; j < fooTags.snapshotLength; j++ )
  {
    try
    {
      var fooTag=fooTags.snapshotItem(j);
      var fooText=fooTag.innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
      fooTag.innerHTML='<textarea>'+fooText+'</textarea>';
      window.foo.xslt[fooTag.id]=x$proc(fooText);
    }
    catch (e) {alert ("xslt "+fooTag.id+":\n"+e.message)}
  }
}
Navigation
generic heading