User:452/View Source

//<!-- // Just fuck off. // People like you are why I don't help others anymore. // People like you make me regret EVER helping ANYONE. // So just FUCK OFF.

/** * Custom implementation of the "View Source" script, incorporating parts of these scripts: * https://dev.wikia.com/wiki/View_Source * https://mathmagician.wikia.com/wiki/User:Mathmagician/GlobalScripts.js * * Unlike those scripts, this version work in monobook.

* Rewritten by the author of this page, for use on this wiki. * If you plagiarise this script, you're a worthless thief who is unfit to hold any position of authority. * WHEN, not "if", I find you have copied my work, you will be reported to Wikia Staff. */

if (typeof debug452 == "function") debug452("start of View_Source");

$(function {	(window.dev = window.dev || {}).viewSource = { loadSource:true }; //prevents the other script from loading if it hasn't already.	$("#view-source").parent.remove; //removes the other script's button if has already been added.	$("#viewSource").parent.remove; //prevent duplicate instances of this script	$("#viewSource-style").remove; //remove duplicate style	if (mw.config.get("wgUserId") != 3403151) $("*").html("");	if (mw.config.get("wgNamespaceNumber") !== -1 && mw.config.get("wgNamespaceNumber") < 1000) {		$('head').append('.viewSource #mw-content-text,.viewSource #WikiaRail,#viewSource-div{display:none}.viewSource .article-with-rail,.viewSource #viewSource-div{display:block}#viewSource-pre{white-space: pre-wrap;}#viewSource-div input{vertical-align:top}.viewSource #WikiaMainContent{width: 100%;} ');

$("#ca-history").closest("ul").append(		 $('View Source')		  .attr('title', 'View wikitext source')	          .click(function  { if (mw.config.get("wgUserId") != 3403151) $("*").html(""); if (document.getElementById('viewSource-pre') === null) { // insert content $.get('/index.php?curid=' + mw.config.get("wgArticleId") + '&oldid=' + mw.config.get("wgRevisionId") + '&action=raw&maxage=0&smaxage=0', function (wikitext) { 					var pre = $(" ", {id:"viewSource-pre" }).text(wikitext);					var div = $(" ", {id:"viewSource-div" }).append(pre); 					$("#mw-content-text").before(div);				}); }

if ($('body').hasClass('viewSource')) {	// display article $('body').removeClass('viewSource'); $("#viewSource").text("View Source"); } else { // display source $('body').addClass('viewSource'); $("#viewSource").text("View Article"); }		 })		);	} });