const NEW_PAGE_DELAY = 1000 const CURRENT_PAGE_DELAY = 300 const getClassNameElementsArray = className => Array.from(document.getElementsByClassName(className)) // Runs on "complete" load and when https://urlurl.url#this-hash-value changes const addFix = fixFunc => { window.addEventListener('load', () => setTimeout(fixFunc, NEW_PAGE_DELAY)) addEventListener('hashchange', () => setTimeout(fixFunc, CURRENT_PAGE_DELAY)) } const getFileName = () => getClassNameElementsArray('file-breadcrumbs-segment-highlighted').map(e => e.innerText)[0] const getCurrentUser = () => { return getClassNameElementsArray("user-dropdown-trigger")[0].title.replace(/(.*\()|\)/g, '') }