Skip to content

Commit

Permalink
fix: tup-715 save patch fix of subdomain link ugly URLs (#468)
Browse files Browse the repository at this point in the history
* fix: tup-715 ugly urls for subdomain links

* docs: tup-715 explain code

* docs: tup-715 more details about code

* style: tup-715 better function name

* fix: TUP-715 check link not doc

Because doc is always tacc. Link is what may not be tacc.
  • Loading branch information
wesleyboar authored Aug 13, 2024
1 parent 3c871cd commit 20b334f
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script type="module" id="js-prevent-ugly-urls-tup-715">
const links = document.querySelectorAll('body > :is(header, main, footer) a[target="_blank"]');

/* HACK: To revert URL of links that Google changes on hover */
/* FAQ: Google Analytics settings interpret subdomain links as URLs to adjust so it can track navigation */
[ ...links ].forEach( function restoreLinkHrefChangedOnHover(link) {
const isTACC = link.host.includes('tacc.utexas.edu');

if ( isTACC ) {
let currentHrefVal = link.getAttribute('href');

link.setAttribute('data-original-href', currentHrefVal );
link.addEventListener('click', () => {
const originalHrefVal = link.getAttribute('data-original-href');

currentHrefVal = link.getAttribute('href');
if ( currentHrefVal !== originalHrefVal ) {
link.setAttribute('href', originalHrefVal );
}
});
}
});
</script>

0 comments on commit 20b334f

Please sign in to comment.