mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: correct type of $
This commit is contained in:
parent
6c671da520
commit
dcaa58a31b
2 changed files with 6 additions and 6 deletions
|
|
@ -7,8 +7,8 @@ import { CopyFileButton, copyFileButtonClassName } from './CopyFileButton'
|
||||||
|
|
||||||
export function resolveMeta(): Partial<MetaData> {
|
export function resolveMeta(): Partial<MetaData> {
|
||||||
const metaData = {
|
const metaData = {
|
||||||
userName: $('[itemprop="author"] > a[rel="author"]', e => e.textContent?.trim()),
|
userName: $('[itemprop="author"] > a[rel="author"]', e => e.textContent?.trim()) || undefined,
|
||||||
repoName: $('[itemprop="name"] > a[href]', e => e.textContent?.trim()),
|
repoName: $('[itemprop="name"] > a[href]', e => e.textContent?.trim()) || undefined,
|
||||||
branchName: getCurrentBranch(true),
|
branchName: getCurrentBranch(true),
|
||||||
}
|
}
|
||||||
if (!metaData.userName || !metaData.repoName) {
|
if (!metaData.userName || !metaData.repoName) {
|
||||||
|
|
@ -65,7 +65,7 @@ export function getCurrentBranch(passive = false) {
|
||||||
|
|
||||||
const findFileButtonSelector =
|
const findFileButtonSelector =
|
||||||
'#js-repo-pjax-container .repository-content .file-navigation a[data-hotkey="t"]'
|
'#js-repo-pjax-container .repository-content .file-navigation a[data-hotkey="t"]'
|
||||||
const urlFromFindFileButton: string | undefined = $(
|
const urlFromFindFileButton = $(
|
||||||
findFileButtonSelector,
|
findFileButtonSelector,
|
||||||
element => (element as HTMLAnchorElement).href,
|
element => (element as HTMLAnchorElement).href,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -38,17 +38,17 @@ export function setBodyIndent(shouldShowGitako: boolean) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $(selector: string): HTMLElement | null
|
export function $(selector: string): HTMLElement | null
|
||||||
export function $<T1>(selector: string, existCallback: (element: HTMLElement) => T1): T1
|
export function $<T1>(selector: string, existCallback: (element: HTMLElement) => T1): T1 | null
|
||||||
export function $<T1, T2>(
|
export function $<T1, T2>(
|
||||||
selector: string,
|
selector: string,
|
||||||
existCallback: (element: HTMLElement) => T1,
|
existCallback: (element: HTMLElement) => T1,
|
||||||
otherwise: () => T2,
|
otherwise: () => T2,
|
||||||
): T1 | T2
|
): T1 | T2 | null
|
||||||
export function $<T2>(
|
export function $<T2>(
|
||||||
selector: string,
|
selector: string,
|
||||||
existCallback: undefined | null,
|
existCallback: undefined | null,
|
||||||
otherwise: () => T2,
|
otherwise: () => T2,
|
||||||
): HTMLElement | null | T2
|
): HTMLElement | T2 | null
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export function $(selector: string, existCallback?: any, otherwise?: any) {
|
export function $(selector: string, existCallback?: any, otherwise?: any) {
|
||||||
const element = document.querySelector(selector)
|
const element = document.querySelector(selector)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue