|
@ -3,9 +3,11 @@ |
|
|
const path = location.pathname; |
|
|
const path = location.pathname; |
|
|
const isDashboard = path === '/' || /(^\/(dashboard))/.test(path) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(path); |
|
|
const isDashboard = path === '/' || /(^\/(dashboard))/.test(path) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(path); |
|
|
const isRepo = /^\/[^/]+\/[^/]+/.test(path); |
|
|
const isRepo = /^\/[^/]+\/[^/]+/.test(path); |
|
|
|
|
|
const isCompare = /^\/[^/]+\/[^/]+\/compare/.test(path); |
|
|
const ownerName = path.split('/')[1]; |
|
|
const ownerName = path.split('/')[1]; |
|
|
const repoName = path.split('/')[2]; |
|
|
const repoName = path.split('/')[2]; |
|
|
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname); |
|
|
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname); |
|
|
|
|
|
const isCommit = () => /^\/[^/]+\/[^/]+\/commit/.test(path); |
|
|
const isIssue = () => /^\/[^/]+\/[^/]+\/issues\/\d+$/.test(location.pathname); |
|
|
const isIssue = () => /^\/[^/]+\/[^/]+\/issues\/\d+$/.test(location.pathname); |
|
|
const isReleases = () => isRepo && /^\/[^/]+\/[^/]+\/(releases|tags)/.test(location.pathname); |
|
|
const isReleases = () => isRepo && /^\/[^/]+\/[^/]+\/(releases|tags)/.test(location.pathname); |
|
|
const isBlame = () => isRepo && /^\/[^/]+\/[^/]+\/blame\//.test(location.pathname); |
|
|
const isBlame = () => isRepo && /^\/[^/]+\/[^/]+\/blame\//.test(location.pathname); |
|
@ -288,7 +290,6 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
|
|
|
|
|
|
if (isRepo) { |
|
|
if (isRepo) { |
|
|
const isRepoRoot = location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || /(\/tree\/)(\w|\d|\.)+(\/$|$)/.test(location.href); |
|
|
const isRepoRoot = location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || /(\/tree\/)(\w|\d|\.)+(\/$|$)/.test(location.href); |
|
|
const isCommit = path.split('/')[3] === 'commit'; |
|
|
|
|
|
|
|
|
|
|
|
gitHubInjection(window, () => { |
|
|
gitHubInjection(window, () => { |
|
|
addReleasesTab(); |
|
|
addReleasesTab(); |
|
@ -296,7 +297,6 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
if (isPR()) { |
|
|
if (isPR()) { |
|
|
linkifyBranchRefs(); |
|
|
linkifyBranchRefs(); |
|
|
addDeleteForkLink(); |
|
|
addDeleteForkLink(); |
|
|
addMinimizeMaximize(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isPR() || isIssue()) { |
|
|
if (isPR() || isIssue()) { |
|
@ -304,6 +304,10 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
linkifyIssuesInTitles(); |
|
|
linkifyIssuesInTitles(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isPR() || isCommit() || isCompare) { |
|
|
|
|
|
addMinimizeMaximize(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isBlame()) { |
|
|
if (isBlame()) { |
|
|
addBlameParentLinks(); |
|
|
addBlameParentLinks(); |
|
|
} |
|
|
} |
|
@ -312,7 +316,7 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
addReadmeEditButton(); |
|
|
addReadmeEditButton(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isCommit) { |
|
|
if (isCommit()) { |
|
|
addPatchDiffLinks(); |
|
|
addPatchDiffLinks(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|