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')), content; document.title = "Editing " + page + " - " + mw.config.get('wgSiteName'); if ($('.AdminDashboardGeneralHeader').length) { $('.AdminDashboardGeneralHeader h1').text("Editing " + page); } else { $('.header-column.header-title').html(' Editing ' + page + ' '); } $('#mw-content-text p').html('Show Changes   Publish  '); 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) {		  content = d.query.pages[i].revisions[0]["*"];          $('#wpTextbox1').text(content);	    }        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);  }); }