User:Alien333/nobr.js

/* global $, mw */ "use strict"; mw.loader.using(['mediawiki.util'], => {

$( => {    if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) < 0) { // if not editing        return;    }    if (mw.config.get('wgCanonicalNamespace') == 'Page' && mw.config.get('wgPageContentModel') == 'proofread-page') {	    var nobrbtn = mw.util.addPortletLink("p-tb", '#', 'Nobr', 'nobr', "Remove line breaks and do a little bit of formatting.");	    $(nobrbtn).click(event => { event.preventDefault; nobr; });   }  }); }); function nobr { // remove line breaks for regular texts	var l = $('#wpTextbox1').val;	l = l.split("\n\n").map((s) => s.replaceAll("\n", " ").replaceAll("- ", "")).join("\n\n").trim;    $('#wpTextbox1').val(l);    doclean; }