User:Suffusion of Yellow/viewsource.js

/* * Adds a "view source" option to editable pages. * Based on User:Misza13/viewSource.js. */

// $.when(mw.loader.using(['mediawiki.util']), $.ready).then(function {	var $editlink = $('#ca-edit a');

if ($editlink.length == 1) { mw.util.addPortletLink(			'p-cactions',			$editlink.attr('href').replace(/&(ve)?action=[^&]+/, '&action=submit&viewsource=1'),			'View source',			'ca-viewsource-hack',			'View the source of this page'		); }

if (mw.config.get('wgAction') == 'submit' &&		location.href.indexOf('viewsource=1') !== -1) {

$('#wpTextbox1').prop('readOnly', true);

// Removing too much can cause other scripts to fail. Just hide it. mw.util.addCSS('div.editOptions, div.mw-editTools, div.wikiEditor-ui-top, form#editform div#editpage-specialchars { display: none; }');

document.title = document.title.replace(/^Editing/, 'View source for'); $('#firstHeading').text($('#firstHeading').text.replace(/^Editing/, 'View source for'));

$('#ca-viewsource-hack').addClass('selected'); $('#ca-edit').removeClass('selected'); } }); //