JSFiddle - React, Tailwind, and code Playground

by René Lücking

HTML

<a target="_blank" href="https://www.google.com">Without existing query string</a>
<br>
<a target="_blank" href="https://www.google.com/search?q=wordpress">With existing query string</a>

JavaScript

jQuery(document).ready(function(){
	jQuery( 'a' ).each( function( index, element ){
		var url = jQuery( element ).prop( 'href' );
		
		if ( url.indexOf( '?' ) == -1 ) {
			url += '?clean=1';
		} else {
			url += '&clean=1';
		}

		jQuery( element ).prop( 'href', url );
	} );
});