27 lines
970 B
JavaScript
27 lines
970 B
JavaScript
const NEW_PAGE_DELAY = 1000
|
|
const CURRENT_PAGE_DELAY = 300
|
|
|
|
const getClassNameElementsArray = className =>
|
|
Array.from(document.getElementsByClassName(className))
|
|
|
|
const querySelectorAllArray = selector =>
|
|
Array.from(document.querySelectorAll(selector))
|
|
|
|
/// Runs on "complete" load and when `https://website.tld#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, '')
|
|
}
|
|
|
|
const addStyle = css => {
|
|
const styleElement = document.createElement('style')
|
|
styleElement.innerText = css.replaceAll("\n", " ")
|
|
document.head.appendChild(styleElement)
|
|
}
|