Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Fix bug: table update error while using file view #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,24 @@ const checkForRepoPage = async () => {
const ns = document.querySelector('ul.UnderlineNav-body')
const navElem = document.getElementById(NAV_ELEM_ID)
const tdElems = document.querySelector('span.github-repo-size-div')

// whether 'add file' button is present
const viewingDir = document.querySelector('div.file-navigation.mb-3.d-flex.flex-items-start > details.details-overlay.details-reset.position-relative > summary > span.btn.d-none.d-md-flex.flex-items-center') || document.querySelector('div.file-navigation.mb-3.d-flex.flex-items-start > div.d-flex > details > summary > span.btn.d-none.d-md-flex.flex-items-center')
msvamp marked this conversation as resolved.
Show resolved Hide resolved

if (ns && !navElem) {
getAPIData(repoObj.repo).then(summary => {
if (summary && summary.size) {
ns.insertAdjacentHTML('beforeend', getSizeHTML(summary.size * 1024))
const newLiElem = document.getElementById(NAV_ELEM_ID)
newLiElem.title = 'Click to load directory sizes'
newLiElem.style.cssText = 'cursor: pointer'
newLiElem.onclick = loadDirSizes
if(viewingDir) {
newLiElem.title = 'Click to load directory sizes'
newLiElem.onclick = loadDirSizes
}
}
})
}

if (tdElems) return
if (!viewingDir || tdElems) return

const tree = await getAPIData(`${repoObj.repo}/contents/${repoObj.currentPath}?ref=${repoObj.ref}`)
const sizeObj = { '..': '..' }
Expand Down