Last active
December 2, 2022 00:14
-
-
Save titangene/a57d340d3620feb1467e5405959f1923 to your computer and use it in GitHub Desktop.
redirect GitHub page <---> GitHub repo page
This file contains hidden or 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
(() => { | |
if (location.hostname === 'github.com') { | |
const [_, username, repo] = location.pathname.split('/'); | |
location.href = `https://${username}.github.io/${repo}`; | |
return; | |
} | |
if (location.hostname.includes('github.io')) { | |
const username = location.host.split('.')[0]; | |
const repo = location.pathname.split('/')[1]; | |
location.href = `https://github.com/${username}/${repo}`; | |
return; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment