User:Sander Säde/viewsource.js

//script to view source quickly $(ViewSourceButton); function ViewSourceButton { mw.util.addPortletLink("p-cactions", "javascript:viewSourceQuick", "source"); }

function viewSourceQuick { var ssourceajax = sajax_init_object; var addr = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=" + mw.config.get('wgPageName') + "&action=raw" ssourceajax.open("GET", addr, true); ssourceajax.onreadystatechange = function {    if(ssourceajax.readyState != 4) return; var csub = document.getElementById("contentSub"); if (mw.config.get('wgTitle') == "Main Page") { var p = document.createElement("code"); csub = document.getElementById("top").appendChild(p); } csub.innerHTML = " " + ssourceajax.responseText.replace(//g,"&gt;").replace(/\n/g," ") + " "; }; ssourceajax.send(null); }