User:Danski454/ToggleSmall.js

function addTags(tagtype, replacement){ while ($('#mw-content-text').find('.'+replacement).length !== 0) { //console.log('2'); var tag = $('#mw-content-text .' + replacement).first; tag.before('<'+tagtype+'>' + tag.html + ''); tag.remove; } }

function removeTags(tagtype, replacement){ while ($('#mw-content-text').find(tagtype).length !== 0) { //console.log('2'); var tag = $('#mw-content-text ' + tagtype).first; tag.before('' + tag.html + ' '); tag.remove; } }

var formatting = true; $(document).ready(function{	if( mw.config.get( 'wgIsArticle' )) {//only on non-special view pages		var portletLink = mw.util.addPortletLink('p-cactions', '#', 'Toggle formatting', 'ca-toggle-fmt', 'Toggle small, large and struck text', '');		$(portletLink).click(function { if (formatting) { removeTags('small', 'toggled_small'); removeTags('big', 'toggled_big'); removeTags('s', 'toggled_struck'); console.log('Cleared formatting'); formatting = false; } else { addTags('small', 'toggled_small'); addTags('big', 'toggled_big'); addTags('s', 'toggled_struck'); console.log('Added formatting'); formatting = true; }		});	} });