feat: show pull request title

This commit is contained in:
EnixCoda 2020-06-26 21:26:22 +08:00
parent e4a9277d12
commit 86a06f098b
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
2 changed files with 9 additions and 1 deletions

View file

@ -10,6 +10,12 @@ export function isInCodePage() {
return Boolean($(branchListSelector))
}
export function getIssueTitle() {
const title = $('.gh-header-title .js-issue-title')?.textContent
const id = $('.gh-header-title .gh-header-number')?.textContent
if (title && id) return `${id} ${title}`
}
export function getCurrentBranch() {
const selectedBranchButtonSelector = [
'.repository-content #branch-select-menu summary',

View file

@ -73,7 +73,9 @@ export const GitHub: Platform = {
}
let detectedBranchName
if (DOMHelper.isInCodePage()) {
if (URLHelper.isInPullPage()) {
detectedBranchName = DOMHelper.getIssueTitle()
} else if (DOMHelper.isInCodePage()) {
// not working well with non-branch blob
// cannot handle '/' split branch name, should not use when possibly on branch page
detectedBranchName = DOMHelper.getCurrentBranch() || URLHelper.parseSHA()