alert / confirm / prompt from a page came up as bare OS message boxes titled "theseus-navigator" (the package name), with no hint of who was asking and nothing of the browser's styling — the PDF Editor's "Delete signature?" was the reported case. The session preload replaces the page's three functions with wrappers that hand the call to the isolated world through a DOM event, which asks main synchronously and writes the answer back; pages see Chrome's return values (confirm → boolean, prompt → string or null) and no new global. Main answers from a sheet hanging under the toolbar, in the same surface as add-on approvals, that names who is asking: the site's host, the add-on's name for an add-on page or panel (identified by its path under the profile's extensions directory), or Theseus for its own pages. The sheet belongs to the tab that asked — hidden while another tab is in front, back when its tab returns — and a closing tab or window answers "cancel" so no renderer stays blocked. Windows without the chrome (installed apps, plain windows) get a native box with a proper title, and app.name now reads "Theseus Navigator" for whatever else still shows one.
8 lines
541 B
JavaScript
8 lines
541 B
JavaScript
// Preload for the page-dialog overlay (js-dialog.html): the Theseus-drawn
|
|
// replacement for a page's alert / confirm / prompt. Main pushes one request
|
|
// at a time via `jsdialog-show`; the page answers with `jsdialog-answer`.
|
|
const { contextBridge, ipcRenderer } = require("electron");
|
|
contextBridge.exposeInMainWorld("jsdialog", {
|
|
onShow: (cb) => ipcRenderer.on("jsdialog-show", (_e, req) => cb(req)),
|
|
answer: (reqId, ok, value) => ipcRenderer.invoke("jsdialog-answer", reqId, !!ok, value == null ? null : String(value)),
|
|
});
|