User:MZMcBride/stripredlinks.js

/** * This code adds a link to the "Toolbox" section ("p-tb") of the sidebar. */ addOnloadHook(function { mw.util.addPortletLink('p-tb', 'javascript:stripredlinks', 'Remove red links', 't-unred', 'Remove all red  links on this page'); })

/** * This code looks at the  HTML element inside list items in a page's body content. * Red links have the attribute class="new" (so that CSS can make them red). * This script just looks for that particular class and then removes those elements. */ function stripredlinks { var lis = document.getElementById('bodyContent').getElementsByTagName('li'); for(var i=lis.length-1;i>-1;i--) { var as = lis[i].getElementsByTagName('a'); for(var j=as.length-1;j>-1;j--) { if(as[j].className.indexOf('new')!=-1) lis[i].parentNode.removeChild(lis[i]) } } }