From cee5ec6b6e2290de169ca3151e72992e01c2db14 Mon Sep 17 00:00:00 2001 From: Nystik <236107-Nystik@users.noreply.gitlab.com> Date: Sat, 9 May 2026 12:23:05 +0200 Subject: [PATCH] dynamically load obsidian scripts from our own index.html --- README.md | 2 +- server/assets/index.html | 29 +++++++++++++++++++++++++++++ server/index.js | 38 ++++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 server/assets/index.html diff --git a/README.md b/README.md index 23cc345..9b3c895 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ This project is licensed under the [GNU Affero General Public License v3.0](LICE Ignis is not affiliated with, endorsed by, or associated with Dynalist Inc. or Obsidian. -Ignis is an independently developed interoperability tool. It contains no Obsidian source code, binaries, or assets. No part of Obsidian is distributed, bundled, or included in this repository. Obsidian's own files are not altered, patched, or modified on disk. The shim is loaded before Obsidian at runtime and intercepts API calls in memory. +Ignis is an independently developed interoperability tool. It contains no Obsidian source code, binaries, or assets. No part of Obsidian is distributed, bundled, or included in this repository. Ignis serves its own HTML page that loads the shim layer, then dynamically loads Obsidian's unmodified scripts. Obsidian's own files are never altered, patched, or transformed, either on disk or in transit. Ignis works by providing a compatibility layer that implements browser-compatible equivalents of the Node.js and Electron APIs that Obsidian depends on. The user must obtain their own licensed copy of Obsidian separately. Ignis has no standalone functionality without it. diff --git a/server/assets/index.html b/server/assets/index.html new file mode 100644 index 0000000..28733ff --- /dev/null +++ b/server/assets/index.html @@ -0,0 +1,29 @@ + + + + + + Obsidian + + + + + + + + + + + + diff --git a/server/index.js b/server/index.js index f824fb8..aa897ce 100644 --- a/server/index.js +++ b/server/index.js @@ -82,30 +82,36 @@ app.use("/vault-files", (req, res, next) => { express.static(vaultPath)(req, res, next); }); -// Serve index.html with ignis scripts injected in-flight (no files modified on disk) +// Serve our own index.html. Obsidian's scripts are discovered at startup +// and injected dynamically by the client -- no Obsidian files are read or +// transformed in the response. let cachedHtml = null; -function getInjectedHtml() { +function buildIndexHtml() { if (cachedHtml) { return cachedHtml; } - const htmlPath = path.join(config.obsidianAssetsPath, "index.html"); - let html = fs.readFileSync(htmlPath, "utf-8"); - const version = getVersion(); - html = html.replace( - "", - ' \n', - ); + // Discover Obsidian's script tags from their index.html + const obsidianHtmlPath = path.join(config.obsidianAssetsPath, "index.html"); + const obsidianHtml = fs.readFileSync(obsidianHtmlPath, "utf-8"); + const scriptRegex = /]+src="([^"]+)"[^>]*>/g; + const scripts = []; + let match; - html = html.replace( - '\n` + - `\n` + - '