fix: #803 enable custom JS (again!)

This commit is contained in:
jamesread 2026-02-15 01:03:22 +00:00
parent 903fd15bdb
commit 7dcbca31fc
2 changed files with 20 additions and 0 deletions

View File

@ -61,6 +61,14 @@ async function initClient () {
window.client = createClient(OliveTinApiService, transport) window.client = createClient(OliveTinApiService, transport)
window.initResponse = await window.client.init({}) window.initResponse = await window.client.init({})
if (window.initResponse.enableCustomJs) {
const script = document.createElement('script')
script.src = '/custom-webui/custom.js'
script.async = true
script.id = 'olivetin-custom-js'
document.head.appendChild(script)
}
const i18nSettings = createI18n({ const i18nSettings = createI18n({
legacy: false, legacy: false,
locale: getSelectedLanguage(), locale: getSelectedLanguage(),

View File

@ -231,6 +231,7 @@ function updateHeaderFromInit() {
} }
applyStyleMods() applyStyleMods()
loadCustomJsIfEnabled()
renderNavigation() renderNavigation()
applyTheme() applyTheme()
@ -369,6 +370,17 @@ function applyTheme() {
} }
} }
function loadCustomJsIfEnabled() {
if (!window.initResponse?.enableCustomJs || document.getElementById('olivetin-custom-js')) {
return
}
const script = document.createElement('script')
script.src = '/custom-webui/custom.js'
script.async = true
script.id = 'olivetin-custom-js'
document.head.appendChild(script)
}
function applyStyleMods() { function applyStyleMods() {
if (!window.initResponse || !window.initResponse.styleMods) { if (!window.initResponse || !window.initResponse.styleMods) {
return return