diff --git a/Jadefin.js b/Jadefin.js index 929aa10..f008f0c 100644 --- a/Jadefin.js +++ b/Jadefin.js @@ -9,6 +9,7 @@ import JadefinUtils from "./JadefinUtils.js"; export default JadefinIntegrity("Jadefin", import.meta.url, () => window["Jadefin"] = new (class Jadefin extends JadefinMod { modUrl = import.meta.url; root = this.modUrl.substring(0, this.modUrl.lastIndexOf("/")); + version = this.root.substring(this.root.lastIndexOf("/") + 1); /** @type {{[id: string]: JadefinMod}} */ mods = {}; diff --git a/JadefinModules.js b/JadefinModules.js index c393390..131ae4e 100644 --- a/JadefinModules.js +++ b/JadefinModules.js @@ -237,4 +237,12 @@ export default JadefinIntegrity("JadefinModules", import.meta.url, () => window[ return this._.events ??= this.Jadefin.findWebpackRawLoad(e => e.Events?.on && e.Events?.off && e.Events?.trigger && 1)[0]?.Events; } + // index.jsx + /** + @return {any} + */ + get index() { + return this._.index ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o._minServerVersion))[0]; + } + })()); diff --git a/mods/ExtrasMenu.css b/mods/ExtrasMenu.css index c9e3252..1e37d70 100644 --- a/mods/ExtrasMenu.css +++ b/mods/ExtrasMenu.css @@ -12,3 +12,11 @@ pointer-events: none; opacity: 0.5; } + +.extrasVersion { + cursor: default; + user-select: none; + line-height: 2em; + opacity: 0.5; + font-size: 0.8em; +} diff --git a/mods/ExtrasMenu.js b/mods/ExtrasMenu.js index 4ab67c2..7f11c70 100644 --- a/mods/ExtrasMenu.js +++ b/mods/ExtrasMenu.js @@ -2,6 +2,7 @@ import JadefinIntegrity from '../JadefinIntegrity.js'; +import Jadefin from "../Jadefin.js"; import JadefinMod from "../JadefinMod.js"; import JadefinModules from "../JadefinModules.js"; import JadefinUtils from "../JadefinUtils.js"; @@ -48,6 +49,13 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class `; + drawerVersionEl = rd$()` +
+ Jellyfin
+ Jadefin +
+ `; + constructor() { super(); @@ -106,6 +114,17 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class } drawer?.insertBefore(this.drawerExtrasEl, userMenuOptions); + drawer?.appendChild(this.drawerVersionEl); + + const versionJellyfinEl = this.drawerVersionEl.querySelector("#extrasVersionJellyfin"); + if (versionJellyfinEl) { + versionJellyfinEl.textContent = JadefinModules.ApiClient.appVersion(); + } + + const versionJadefinEl = this.drawerVersionEl.querySelector("#extrasVersionJadefin"); + if (versionJadefinEl) { + versionJadefinEl.textContent = Jadefin.version; + } this.update(); } @@ -159,30 +178,28 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class } update() { - if (this.drawerExtrasEl) { - this.drawerExtrasEl.innerHTML = `

Extras

`; + this.drawerExtrasEl.innerHTML = `

Extras

`; - for (let item of this._items) { - if (!this.checkVisibility(this.IN_DRAWER, item)) { - continue; - } - - let itemEl = rd$()` - - - - - `; - - itemEl.addEventListener("click", e => item.cb?.()); - - item.cbEl?.(itemEl, this.IN_DRAWER); - - this.drawerExtrasEl.appendChild(itemEl); + for (let item of this._items) { + if (!this.checkVisibility(this.IN_DRAWER, item)) { + continue; } + + let itemEl = rd$()` + + + + + `; + + itemEl.addEventListener("click", e => item.cb?.()); + + item.cbEl?.(itemEl, this.IN_DRAWER); + + this.drawerExtrasEl.appendChild(itemEl); } }