fix: resolve new GitHub DOM

This commit is contained in:
EnixCoda 2020-07-17 12:01:20 +08:00
parent db8ec597df
commit 17f785e5c4
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4
3 changed files with 9 additions and 6 deletions

View file

@ -5,6 +5,14 @@ import { $ } from 'utils/DOMHelper'
import { renderReact } from 'utils/general'
import { CopyFileButton, copyFileButtonClassName } from './CopyFileButton'
export function isInRepoPage() {
const repoHeadSelector = '.repohead' // legacy
const authorNameSelector = '.author[itemprop="author"]'
return Boolean(
document.querySelector(repoHeadSelector) || document.querySelector(authorNameSelector),
)
}
export function isInCodePage() {
const branchListSelector = ['#branch-select-menu', '.branch-select-menu'].join()
return Boolean($(branchListSelector))

View file

@ -24,11 +24,6 @@ export function parseSHA() {
return type === 'blob' || type === 'tree' ? path[0] : undefined
}
export function isInRepoPage() {
const repoHeaderSelector = '.repohead'
return Boolean(document.querySelector(repoHeaderSelector))
}
export function isInPullPage() {
const { type, path } = parse()
return type === 'pull' ? path[0] : false

View file

@ -69,7 +69,7 @@ export function isEnterprise() {
export const GitHub: Platform = {
isEnterprise,
resolveMeta() {
if (!URLHelper.isInRepoPage()) {
if (!DOMHelper.isInRepoPage()) {
return null
}