Skip to content

Instantly share code, notes, and snippets.

@antons
Last active March 29, 2016 04:30
Show Gist options
  • Save antons/2802261 to your computer and use it in GitHub Desktop.
Save antons/2802261 to your computer and use it in GitHub Desktop.
Script to automatically replace `http://` with `macappstore://` (and `https://` with `macappstores://`) on Lion, Mountain Lion, and Mavericks.
// 1. Add `data-mac-app-store` attribute to all Mac App Store links.
// 2. Use this script to automatically replace `http://` with `macappstore://` (and `https://` with `macappstores://`) for those links on Lion, Mountain Lion, and Mavericks.
if (/Mac OS X 10[_.][0-9]/i.test(navigator.userAgent)) {
var MASLinks = document.querySelectorAll('a[data-mac-app-store]')
for (var MASLinkIndex = 0; MASLinkIndex < MASLinks.length; MASLinkIndex++) {
var MASLink = MASLinks[MASLinkIndex]
MASLink.setAttribute('href', MASLink.getAttribute('href').replace(/^http/, 'macappstore'))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment