Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build-chrome": "cross-env TARGET=chrome node utils/build.js",
"build-firefox": "cross-env TARGET=firefox node utils/build.js",
"start": "yarn start-chrome",
"start-chrome": "cross-env NODE_ENV=development TARGET=chrome node utils/start.js",
"start-firefox": "cross-env NODE_ENV=development TARGET=firefox node utils/start.js",
"start-chrome": "cross-env NODE_OPTIONS='--openssl-legacy-provider' NODE_ENV=development TARGET=chrome node utils/start.js",
"start-firefox": "cross-env NODE_OPTIONS='--openssl-legacy-provider' NODE_ENV=development TARGET=firefox node utils/start.js",
"standard": "standard",
"test": "jest --watch",
"test-ci": "jest"
Expand Down Expand Up @@ -44,7 +44,7 @@
"write-file-webpack-plugin": "^4.5.1"
},
"devDependencies": {
"cross-env": "^5.2.0",
"cross-env": "^7.0.3",
"husky": "^0.13.4",
"jest": "^27.0.6",
"sanitize-html": "^2.3.2",
Expand Down
39 changes: 23 additions & 16 deletions src/js/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ import './style.css'

const { document, MutationObserver, FontFace, parseInt = Number.parseInt } = window

let observer
const observe = () => {
observer && observer.disconnect()
const pjaxContainer = document.querySelector('[data-pjax-container]')
const pjaxContentContainer = document.querySelector('#repo-content-pjax-container')
observer = new MutationObserver(start)
pjaxContainer && observer.observe(pjaxContainer, { childList: true })
pjaxContentContainer && observer.observe(pjaxContentContainer, { childList: true })
function waitForElm (selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector))
}

const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector))
observer.disconnect()
}
})

observer.observe(document.body, {
childList: true,
subtree: true
})
})
}

class Top extends React.Component {
Expand All @@ -29,7 +39,7 @@ class Top extends React.Component {
this.calculateTree()
}

loadTree() {
loadTree () {
const { tree } = createFileTree()
this.setState({ tree })
}
Expand Down Expand Up @@ -93,11 +103,8 @@ const loadFonts = () => {
})
}

const start = () => {
observe()
renderTree()
}

loadFonts()
observe()
start()
renderTree()
waitForElm('#files_tab_counter').then(() => {
renderTree()
})
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2726,14 +2726,14 @@ create-error-class@^3.0.0:
dependencies:
capture-stack-trace "^1.0.0"

cross-env@^5.2.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.1.tgz#b2c76c1ca7add66dc874d11798466094f551b34d"
integrity sha512-1yHhtcfAd1r4nwQgknowuUNfIT9E8dOMMspC36g45dN+iD1blloi7xp8X/xAIDnjHWyt1uQ8PHk2fkNaym7soQ==
cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
dependencies:
cross-spawn "^6.0.5"
cross-spawn "^7.0.1"

cross-spawn@^6.0.0, cross-spawn@^6.0.5:
cross-spawn@^6.0.0:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
Expand All @@ -2744,7 +2744,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down