User:SoledadKabocha/cleanArrows.js

function cleanArrowMarkup { var editbox = $( '#wpTextbox1' ); if ( !editbox ) return; var editboxtext = editbox.val; if ( typeof editboxtext != 'string' ) return;

var neweditboxtext = editboxtext; neweditboxtext = neweditboxtext.replace( /&larr;/g, '←' ).replace( /&rarr;/g, '→' ); neweditboxtext = neweditboxtext.replace( /&le;/g,  '≤' ).replace( /&ge;/g,   '≥' ); neweditboxtext = neweditboxtext.replace( /&asymp;/g, '≈' ); neweditboxtext = neweditboxtext.replace( /&sect;/g, '§' ); neweditboxtext = neweditboxtext.replace( / &mdash;/g, ' –' ); // unlike entities, tags are not case-sensitive neweditboxtext = neweditboxtext.replace( / /gi, ' ' );

if ( neweditboxtext == editboxtext ) { mw.notify( 'Nothing to replace', { tag: 'cleanarrows' } ); } else { editbox.val( neweditboxtext ); } }

// edit, submit // XXX: should also check for wgPageContentModel=='wikitext'? if ( /it$/.test( mw.config.get( 'wgAction' ) ) ) { $( function {    var plnk = mw.util.addPortletLink( 'p-cactions', '#cm-' + Math.random, 'Clean→', 'ca-cleanarrowmarkup' );   $( plnk ).click( function ( e ) { e.preventDefault; cleanArrowMarkup; }); }); }