2023-02-02 14:36:40 -05:00
|
|
|
const NEW_PAGE_DELAY = 1000
|
|
|
|
const CURRENT_PAGE_DELAY = 300
|
|
|
|
|
|
|
|
const getClassNameElementsArray = className =>
|
2023-02-02 15:57:09 -05:00
|
|
|
Array.from(document.getElementsByClassName(className))
|
2023-02-02 14:36:40 -05:00
|
|
|
|
2023-12-04 10:04:20 -05:00
|
|
|
const querySelectorAllArray = selector =>
|
|
|
|
Array.from(document.querySelectorAll(selector))
|
|
|
|
|
2023-02-07 14:01:47 -05:00
|
|
|
/// Runs on "complete" load and when `https://website.tld#this-hash-value` changes
|
2023-02-02 14:36:40 -05:00
|
|
|
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]
|
2023-02-02 15:57:09 -05:00
|
|
|
|
|
|
|
const getCurrentUser = () => {
|
|
|
|
return getClassNameElementsArray("user-dropdown-trigger")[0].title.replace(/(.*\()|\)/g, '')
|
|
|
|
}
|
2023-02-07 15:04:56 -05:00
|
|
|
|
|
|
|
const addStyle = css => {
|
|
|
|
const styleElement = document.createElement('style')
|
|
|
|
styleElement.innerText = css.replaceAll("\n", " ")
|
|
|
|
document.head.appendChild(styleElement)
|
|
|
|
}
|