iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐈⬛
Bookmarklet to open the source repository from a github.io page
This is a bookmarklet that jumps to the source code repository when you are viewing a page published using GitHub Pages.
It supports URLs in the format [id].github.io or [id].github.io/[repository].
javascript: (() => {
const githubIoUrlToRepoUrl = (url) => {
const m = url.match(/(([^/]+).github.io)\/?([^/]*)/)
if (!m) {
return false
}
const [, host, githubId, repoPath] = m
const repo = repoPath || host
return `http://github.com/${githubId}/${repo}`
}
const url = githubIoUrlToRepoUrl(location.href)
console.log(url)
if (!url) {
alert('not github.io repository')
return
}
location.href = url
})()
Discussion