User:Efitu/ViewSource.js

/* I can't make this work, I'm just leaving this here. >_< */

function efitu_viewSource{ var edit_page = document.getElementById('ca-edit');

if (wgPageName == "MediaWiki:Blank"){

var query = window.location.search; var rx = /[\?&]efitu_source_page=([^&+])/;

if (rx.test(query)){ var res = rx.exec(query); var page = rx[1]; var content = document.getElementById('bodyContent'); content.innerHTML = ' This is the source of the page . ' +               ' ( Loading... ) ' + '  ';

document.getElementById('efitu_viewSource_pageName').appendChild(document.createTextNode(pageName)); document.getElementById('efitu_viewSource_back').appendChild(document.createTextNode("<< Back to " + pageName + " <<")); document.getElementById('efitu_viewSource_back').href = wgScriptPath + '?title=' encodeURIComponent(pageName); }

} else if (edit_page){ var source_url = window.wgScript + "?title=MediaWiki:Blank&efitu_source_page=" + encodeURIComponent(mw.config.get('wgPageName')); var li = document.createElement("li"); var a = document.createElement("a"); a.href = source_url; a.title = "View the source code of this page without editing."; a.innerHTML = " View Source "; li.appendChild(a); edit_page.parentNode.insertBefore(li, edit_page); } }

if (window.attachEvent) window.attachEvent('onload', efitu_viewSource); else if (window.addEventListener) window.addEventListener('load', efitu_viewSource, false);