User:Sander Säde/viewsource.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//script to view source quickly addOnloadHook(ViewSourceButton); function ViewSourceButton() { addPortletLink( chooseBox('source', TwinkleConfig.toolboxButtons), "javascript:viewSourceQuick()", "source", "", "", ""); } function viewSourceQuick() { var ssourceajax = sajax_init_object(); var addr = wgServer + wgScriptPath + "/index.php?title=" + wgPageName + "&action=raw" ssourceajax.open("GET", addr, true); ssourceajax.onreadystatechange = function() { if(ssourceajax.readyState != 4) return; var csub = document.getElementById("contentSub"); if (wgTitle == "Main Page") { var p = document.createElement("code"); csub = document.getElementById("top").appendChild(p); } csub.innerHTML = "<nowiki>" + ssourceajax.responseText.replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br/>") + "</nowiki>"; }; ssourceajax.send(null); }

