class Main { constructor() {} async Init() { await this.Get() } #Loading() {} async Get(x) { this.object = { session: document.cookie, url: window.location.href } this.fetch = '/' if (x) this.fetch = x await fetch(this.fetch, { method: 'post', body: JSON.stringify(this.object), headers: new Headers({ 'Content-Type': 'application/json' }) }) .then(res => res.json()) .then(output => { const head = document.getElementsByTagName('head')[0] const body = document.getElementsByTagName('body')[0] const section = document.getElementById('main') for (let i = 0; i < output.css.length; i++) { const link = document.createElement('link') link.rel = 'stylesheet' link.type = 'text/css' link.href = `${window.location.origin}/css/${output.css[i]}` head.appendChild(link) } for (let i = 0; i < output.js.length; i++) { const script = document.createElement('script') script.src = `${window.location.origin}/js/${output.js[i]}` body.appendChild(script) } section.innerHTML = DOMPurify.sanitize(output.html) }) } } new Main().Init()