Last active
March 29, 2016 04:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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