User:Jeeputer/highlightPiped.js

In this article we are going to delve into the fascinating world of User:Jeeputer/highlightPiped.js and explore all its facets. User:Jeeputer/highlightPiped.js is a fundamental aspect of daily life and throughout history it has played a crucial role in society. From User:Jeeputer/highlightPiped.js it has impacted the way people relate to each other, to its influence on technological and scientific advances. Over the next few lines, we'll take an in-depth look at User:Jeeputer/highlightPiped.js and how it has shaped our world in ways that often go unnoticed. Get ready to immerse yourself in a journey through the complexity and importance of User:Jeeputer/highlightPiped.js in our lives!
$(function () {
	if (mw.config.get('wgNamespaceNumber') !== 0 ) {return} //Only on main namespace
	var portlet = mw.util.addPortletLink(
		window.pipeHighlighterCustomPortlet || 'p-tb',
		'javascript:void(0)',
		'Highlight piped links',
		't-pipehighlighter',
		'Highlight piped links like ]'
		);
	$(portlet).on('click', function(){
		var links = $('#mw-content-text a');
		for (var i = 0; i < links.length; i++) {
		    var link = $(links);
	        var linkText = link.text(),
	            linkTitle = link.attr('title');
		    var color = window.pipeHighlighterCustomColor || '#B3446C';
		    // Check if link is piped
		    if (
		    	link.parents('.navbox').length ||
		    	link.attr('class') === 'extiw' ||
		    	link.parents('.asbox-body').length ||
		    	link.parents('.sistersitebox').length ||
		    	link.parents('.infobox-header').length ||
		    	link.parents('.infobox-label').length ||
		    	link.parents('.mw-editsection').length ||
		    	(link.parents('div.reflist').length || link.parents('div.refbegin').length) || // reflists
		    	linkTitle == undefined ||
		    	linkText === linkTitle ||
		    	(linkTitle !== undefined && linkText === linkTitle.toLocaleLowerCase())
				) {
		    	// Not piped, so continue the loop
		        continue;
			} else {
				// Piped, so check if it's a redirect or disambiguation link
		        if (link.hasClass('mw-redirect') && link.css('color') === 'rgb(0, 102, 0)') {
		        	// Is a colored redirect link, so prepend a colored pipe
		            link.prepend('<span style="color: ' + color + '; font-weight: bold">|</span>');
		        } else if (link.hasClass('mw-disambig') && link.css('color') === 'rgb(241, 118, 0)') {
		        	// Is a colored disambig link, so prepend a pipe
		            link.prepend('<span style="color: ' + color + '; font-weight: bold">|</span>');
		        } else if (link.hasClass('new')) {
		        	// Is a redlink
		        	link.prepend('<span style="color: ' + color + '; font-weight: bold">|</span>');
		        } else {
		        	// Is not a redirect nor a disambig link,
		        	// Or is a redirect or a disambig link without a custom color
		        	// This is intended for compatibility with other link highlighing scripts/gadgets
		            link.css('color', color);
		        }
		        
		    }
		}
	});
});