28 lines
853 B
JavaScript
28 lines
853 B
JavaScript
document.addEventListener("readystatechange", event => {
|
|
if(event.target.readyState === 'complete') {
|
|
initOverflow();
|
|
initExternalLinks();
|
|
initBackground();
|
|
}
|
|
});
|
|
|
|
function initOverflow() {
|
|
let body = document.querySelector('body');
|
|
if (body.scrollHeight > window.outerHeight) {
|
|
body.style.height = 'auto';
|
|
}
|
|
}
|
|
|
|
function initExternalLinks() {
|
|
document.querySelectorAll('a').forEach(elem => {
|
|
if(isExternalURL(elem.getAttribute('href'))) {
|
|
elem.setAttribute('target', '_blank');
|
|
}
|
|
})
|
|
}
|
|
|
|
function initBackground() {
|
|
let text = document.querySelector('.background .background-content').innerHTML;
|
|
document.querySelector('.background .background-content').innerHTML = text + text + text;
|
|
}
|
|
const isExternalURL = (url) => new URL(url).origin !== location.origin; |