From dfe104da429b5e39ed9ec7a10f331ae44d3bebe9 Mon Sep 17 00:00:00 2001 From: smartfrigde <37928912+smartfrigde@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:33:28 +0100 Subject: [PATCH] fix settings webview injection --- src/preload/preload.ts | 15 ++++++++++++++- src/preload/settings.ts | 24 +++--------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/preload/preload.ts b/src/preload/preload.ts index 685e367..c44e3d6 100644 --- a/src/preload/preload.ts +++ b/src/preload/preload.ts @@ -73,11 +73,24 @@ sleep(5000).then(async () => { // Settings info version injection setInterval(() => { + addScript(` + if (document.getElementById("ACsettingsModal") == null) { + var html = '×
'; + const elem = document.createElement("div"); + elem.id = "ACsettingsModal"; + elem.classList.add("ACsettings-modal"); + elem.innerHTML = html; + document.getElementById("app-mount").prepend(elem); + document.getElementById("closeSettings").addEventListener("click", () => { + document.getElementById("webviewSettingsContainer").innerHTML = ""; + document.getElementById("ACsettingsModal").style.display = "none"; + }); + } + `); const host = document.querySelector('[class*="sidebar"] [class*="info"]'); if (!host || host.querySelector("#ac-ver")) { return; } - const el = host.firstElementChild!.cloneNode() as HTMLSpanElement; el.id = "ac-ver"; el.textContent = `ArmCord Version: ${version}`; diff --git a/src/preload/settings.ts b/src/preload/settings.ts index c1f58d7..d133bf8 100644 --- a/src/preload/settings.ts +++ b/src/preload/settings.ts @@ -1,13 +1,7 @@ import * as path from "path"; import * as fs from "fs"; -import {addStyle} from "../utils"; +import {addScript, addStyle} from "../utils"; import {WebviewTag} from "electron"; -var html = ` -