Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( document ).ready( () => {
	if ( document.body.classList.contains( "ns-0" ) ) {
		const query_top = "div.mw-parser-output",
			query_a_not = [ '[href=""]', '[href^="#cite_note-"]', '[href^="#cite_ref-"]' ].join(),
			query_parents_not = [ "h2,h3,h4,h5,h6", "#toc", ".infobox", ".metadata", ".hatnote", ".thumb", ".navbox", ".sortable", ".reflist"].join(),
			query_selector = `${query_top} > *:not( ${query_parents_not} ) a[href]:not( ${query_a_not} )`,
			link_elements = {};
		let fa;
		mw.loader.load( "/w/index.php?title=User:Fred_Gandt/dupeLinks.css&action=raw&ctype=text/css", "text/css" );
		Array.from( document.querySelectorAll( query_selector ) ).filter( a => !a.parentElement.parentElement.classList.contains( "Inline-Template" ) ).forEach( a => {
			fa = link_elements[ a.href ];
			if ( fa ) {
				a.classList.add( "fg-dupe-links-dupe" );
				a.dataset.fg_dupe_links_count = fa.dataset.fg_dupe_links_count = parseInt( fa.dataset.fg_dupe_links_count ) + 1;
			} else {
                a.classList.add( "fg-dupe-links-first" );
                a.dataset.fg_dupe_links_count = 1;
				link_elements[ a.href ] = a;
			}
		} );
		console.log( link_elements ); // TODO make more useful
	}
} );