User:Ozuzanna/noSyntaxHighlight.js

/*
 * *****WORK IN PROGRESS*****
 * No Syntax Highlight
 * @description when trying to edit a MW or User JS/CS page, it will use a surrogate emulated edit model on Special:Blankpage instead to mitigate the terrible syntax highlighting
 * @author Ozuzanna

if ((mw.config.get('wgCanonicalNamespace') === "User" || mw.config.get('wgCanonicalNamespace') === "MediaWiki") && mw.config.get('wgAction') === "view" && (mw.config.get('wgTitle').split('.css') !== -1 || mw.config.get('wgTitle').split('.js') !== -1) && $('#ca-edit').length) $('#ca-edit').attr('href', mw.config.get('wgArticlePath').slice(0,-2) + 'Special:Blankpage?blankspecial=surrogateedit&page=' + mw.config.get('wgPageName'));

if (mw.config.get('wgCanonicalSpecialPageName') == "Blankpage" && $.getUrlVar('blankspecial') == "surrogateedit" && $.getUrlVar('page')) { var page = decodeURIComponent($.getUrlVar('page')); document.title = "Editing " + page + " - " + mw.config.get('wgSiteName'); $('.AdminDashboardGeneralHeader h1').text("Editing " + page); $('#mw-content-text p').html('  '); new mw.Api.get({ action: 'query',  prop: 'revisions',  rvprop: 'content',  titles: page  }) .done(function(d) {   if (!d.error) {      for (var i in d.query.pages) {        if (d.query.pages[i].revisions) {          $('#wpTextbox1').text(d.query.pages[i].revisions[0]["*"]);	    }        else {          $('#wpTextbox1').text('Page ' + page + ' does not exist!');        }        }    }	else {	  $('#wpTextbox1').text('Failed to get contents of ' + page + ': ' + d.error.code);	}  }) .fail(function {   $('#wpTextbox1').text('Failed to get contents of ' + page);  }); }