Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active February 23, 2018 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/320e763506b5c61600c1ed54cbeb6f55 to your computer and use it in GitHub Desktop.
Save billerickson/320e763506b5c61600c1ed54cbeb6f55 to your computer and use it in GitHub Desktop.
// Change Google Maps links to Apple Maps on iOS
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if( !! iOS ) {
var links = document.body.querySelectorAll('.map-link');
links.forEach( function(e) {
var url = e.getAttribute('href').replace('google', 'apple');
e.setAttribute('href', url );
});
}
<a class="map-link" href="https://maps.google.com/?q=6750+West+Loop+South%2C+Suite+920+Bellaire+TX+77401">link to map</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment