2017-10-21 04:37:01 +02:00
|
|
|
"use strict";
|
2026-02-04 11:26:06 +01:00
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
|
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
|
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
|
|
|
}
|
|
|
|
|
Object.defineProperty(o, k2, desc);
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || (function () {
|
|
|
|
|
var ownKeys = function(o) {
|
|
|
|
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
|
|
|
var ar = [];
|
|
|
|
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
|
|
|
return ar;
|
|
|
|
|
};
|
|
|
|
|
return ownKeys(o);
|
|
|
|
|
};
|
|
|
|
|
return function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
const fs = __importStar(require("fs"));
|
2019-01-05 02:17:31 +01:00
|
|
|
const electron_1 = require("electron");
|
2021-01-11 01:56:39 +01:00
|
|
|
const browserView_1 = require("./browserView");
|
2019-04-18 18:03:17 +01:00
|
|
|
let electronSocket;
|
2019-01-05 02:17:31 +01:00
|
|
|
module.exports = (socket) => {
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket = socket;
|
2025-10-13 14:05:33 +02:00
|
|
|
// The crashed event has been removed in Electron 29
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-crashed", (id) => {
|
2019-01-05 02:17:31 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("crashed");
|
2025-10-13 14:05:33 +02:00
|
|
|
// @ts-expect-error No overload matches this call
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.on("crashed", (event, killed) => {
|
|
|
|
|
electronSocket.emit("webContents-crashed" + id, killed);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-didFinishLoad", (id) => {
|
2019-01-05 02:17:31 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("did-finish-load");
|
|
|
|
|
browserWindow.webContents.on("did-finish-load", () => {
|
|
|
|
|
electronSocket.emit("webContents-didFinishLoad" + id);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-didStartNavigation", (id) => {
|
2023-11-03 00:23:37 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("did-start-navigation");
|
|
|
|
|
browserWindow.webContents.on("did-start-navigation", (_, url) => {
|
|
|
|
|
electronSocket.emit("webContents-didStartNavigation" + id, url);
|
2023-11-03 00:23:37 +01:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-didNavigate", (id) => {
|
2023-11-03 00:23:37 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("did-navigate");
|
|
|
|
|
browserWindow.webContents.on("did-navigate", (_, url, httpResponseCode) => {
|
|
|
|
|
electronSocket.emit("webContents-didNavigate" + id, {
|
|
|
|
|
url,
|
|
|
|
|
httpResponseCode,
|
|
|
|
|
});
|
2023-11-03 00:23:37 +01:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-willRedirect", (id) => {
|
2023-11-03 00:23:37 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("will-redirect");
|
|
|
|
|
browserWindow.webContents.on("will-redirect", (_, url) => {
|
|
|
|
|
electronSocket.emit("webContents-willRedirect" + id, url);
|
2023-11-03 00:23:37 +01:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-didFailLoad", (id) => {
|
2023-11-03 00:23:37 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("did-fail-load");
|
|
|
|
|
browserWindow.webContents.on("did-fail-load", (_, errorCode, validatedUrl) => {
|
|
|
|
|
electronSocket.emit("webContents-didFailLoad" + id, {
|
|
|
|
|
errorCode,
|
|
|
|
|
validatedUrl,
|
|
|
|
|
});
|
2023-11-03 00:23:37 +01:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-didRedirectNavigation", (id) => {
|
2023-11-03 00:23:37 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("did-redirect-navigation");
|
|
|
|
|
browserWindow.webContents.on("did-redirect-navigation", (_, url) => {
|
|
|
|
|
electronSocket.emit("webContents-didRedirectNavigation" + id, url);
|
2023-11-03 00:23:37 +01:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-input-event", (id) => {
|
2023-03-24 01:50:13 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("input-event");
|
|
|
|
|
browserWindow.webContents.on("input-event", (_, eventArgs) => {
|
|
|
|
|
if (eventArgs.type !== "char") {
|
|
|
|
|
electronSocket.emit("webContents-input-event" + id, eventArgs);
|
2023-03-24 01:50:13 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-domReady", (id) => {
|
2023-09-24 16:36:41 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.removeAllListeners("dom-ready");
|
|
|
|
|
browserWindow.webContents.on("dom-ready", () => {
|
|
|
|
|
electronSocket.emit("webContents-domReady" + id);
|
2023-09-24 16:36:41 +02:00
|
|
|
});
|
|
|
|
|
});
|
2025-12-04 17:52:01 +00:00
|
|
|
socket.on("webContents-openDevTools", (id, options) => {
|
2017-10-21 04:37:01 +02:00
|
|
|
if (options) {
|
|
|
|
|
getWindowById(id).webContents.openDevTools(options);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
getWindowById(id).webContents.openDevTools();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-getPrinters", async (id) => {
|
2023-03-24 02:17:09 +01:00
|
|
|
const printers = await getWindowById(id).webContents.getPrintersAsync();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-getPrinters-completed", printers);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-print", async (id, options = {}) => {
|
2020-04-19 01:22:27 +02:00
|
|
|
await getWindowById(id).webContents.print(options);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-print-completed", true);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-printToPDF", async (id, options = {}, path) => {
|
2020-04-19 01:22:27 +02:00
|
|
|
const buffer = await getWindowById(id).webContents.printToPDF(options);
|
2019-11-28 22:34:49 +01:00
|
|
|
fs.writeFile(path, buffer, (error) => {
|
2017-10-23 19:08:10 +02:00
|
|
|
if (error) {
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-printToPDF-completed", false);
|
2019-11-28 22:34:49 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-printToPDF-completed", true);
|
2017-10-23 19:08:10 +02:00
|
|
|
}
|
|
|
|
|
});
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-executeJavaScript", async (id, code, userGesture = false) => {
|
2023-09-24 16:36:49 +02:00
|
|
|
const result = await getWindowById(id).webContents.executeJavaScript(code, userGesture);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-executeJavaScript-completed", result);
|
2023-09-24 16:36:49 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-getUrl", function (id) {
|
2019-01-05 02:17:31 +01:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-getUrl" + id, browserWindow.webContents.getURL());
|
2018-03-16 22:32:56 +03:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-allowNTLMCredentialsForDomains", (id, domains) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.allowNTLMCredentialsForDomains(domains);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-clearAuthCache", async (...args) => {
|
2025-11-09 02:33:51 +01:00
|
|
|
// Overload support: (id, guid) OR (id, options, guid)
|
|
|
|
|
const browserWindow = getWindowById(args[0]);
|
|
|
|
|
let guid;
|
|
|
|
|
if (args.length === 2) {
|
|
|
|
|
// No options
|
|
|
|
|
guid = args[1];
|
|
|
|
|
await browserWindow.webContents.session.clearAuthCache();
|
|
|
|
|
}
|
|
|
|
|
else if (args.length === 3) {
|
|
|
|
|
const options = args[1];
|
|
|
|
|
guid = args[2];
|
|
|
|
|
try {
|
2025-11-14 17:38:55 +01:00
|
|
|
// @ts-ignore
|
2025-11-09 02:33:51 +01:00
|
|
|
await browserWindow.webContents.session.clearAuthCache(options);
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
// Fallback to clearing without options if Electron version rejects custom options
|
|
|
|
|
await browserWindow.webContents.session.clearAuthCache();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return; // invalid invocation
|
|
|
|
|
}
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-clearAuthCache-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-clearCache", async (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
await browserWindow.webContents.session.clearCache();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-clearCache-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-clearHostResolverCache", async (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
await browserWindow.webContents.session.clearHostResolverCache();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-clearHostResolverCache-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-clearStorageData", async (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
await browserWindow.webContents.session.clearStorageData({});
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-clearStorageData-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-clearStorageData-options", async (id, options, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
await browserWindow.webContents.session.clearStorageData(options);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-clearStorageData-options-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-createInterruptedDownload", (id, options) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.createInterruptedDownload(options);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-disableNetworkEmulation", (id) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.disableNetworkEmulation();
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-enableNetworkEmulation", (id, options) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.enableNetworkEmulation(options);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-flushStorageData", (id) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.flushStorageData();
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-getBlobData", async (id, identifier, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
const buffer = await browserWindow.webContents.session.getBlobData(identifier);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-getBlobData-completed" + guid, buffer.buffer);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-getCacheSize", async (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
const size = await browserWindow.webContents.session.getCacheSize();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-getCacheSize-completed" + guid, size);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-getPreloads", (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const preloads = browserWindow.webContents.session.getPreloads();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-getPreloads-completed" + guid, preloads);
|
2019-05-16 18:03:31 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-getUserAgent", (id, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const userAgent = browserWindow.webContents.session.getUserAgent();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-getUserAgent-completed" + guid, userAgent);
|
2019-05-16 18:03:31 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-resolveProxy", async (id, url, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
const proxy = await browserWindow.webContents.session.resolveProxy(url);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-resolveProxy-completed" + guid, proxy);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-setDownloadPath", (id, path) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.setDownloadPath(path);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-setPreloads", (id, preloads) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.setPreloads(preloads);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-setProxy", async (id, configuration, guid) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2020-04-19 01:22:27 +02:00
|
|
|
await browserWindow.webContents.session.setProxy(configuration);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-setProxy-completed" + guid);
|
2020-04-19 01:22:27 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-setUserAgent", (id, userAgent, acceptLanguages) => {
|
2019-05-16 18:03:31 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.setUserAgent(userAgent, acceptLanguages);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-session-webRequest-onBeforeRequest", (id, filter) => {
|
2025-10-13 14:05:33 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const session = browserWindow.webContents.session;
|
|
|
|
|
session.webRequest.onBeforeRequest(filter, (details, callback) => {
|
|
|
|
|
socket.emit(`webContents-session-webRequest-onBeforeRequest${id}`, details);
|
|
|
|
|
// Listen for a response from C# to continue the request
|
|
|
|
|
electronSocket.once(`webContents-session-webRequest-onBeforeRequest-response${id}`, (response) => {
|
|
|
|
|
callback(response);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("register-webContents-session-cookies-changed", (id) => {
|
2020-05-22 16:38:34 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.session.cookies.removeAllListeners("changed");
|
|
|
|
|
browserWindow.webContents.session.cookies.on("changed", (event, cookie, cause, removed) => {
|
|
|
|
|
electronSocket.emit("webContents-session-cookies-changed" + id, [
|
|
|
|
|
cookie,
|
|
|
|
|
cause,
|
|
|
|
|
removed,
|
|
|
|
|
]);
|
2020-05-22 16:38:34 +02:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-cookies-get", async (id, filter, guid) => {
|
2020-05-22 16:38:34 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const cookies = await browserWindow.webContents.session.cookies.get(filter);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-cookies-get-completed" + guid, cookies);
|
2020-05-22 16:38:34 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-cookies-set", async (id, details, guid) => {
|
2020-05-22 16:38:34 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
await browserWindow.webContents.session.cookies.set(details);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-cookies-set-completed" + guid);
|
2020-05-22 16:38:34 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-cookies-remove", async (id, url, name, guid) => {
|
2020-05-22 16:38:34 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
await browserWindow.webContents.session.cookies.remove(url, name);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-cookies-remove-completed" + guid);
|
2020-05-22 16:38:34 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-cookies-flushStore", async (id, guid) => {
|
2020-05-22 16:38:34 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
await browserWindow.webContents.session.cookies.flushStore();
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-cookies-flushStore-completed" + guid);
|
2020-05-22 16:38:34 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-loadURL", (id, url, options) => {
|
2020-04-23 03:29:52 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
2023-03-24 01:50:13 +01:00
|
|
|
browserWindow.webContents
|
|
|
|
|
.loadURL(url, options)
|
|
|
|
|
.then(() => {
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-loadURL-complete" + id);
|
2023-03-24 01:50:13 +01:00
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2020-04-23 03:29:52 +02:00
|
|
|
console.error(error);
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-loadURL-error" + id, error);
|
2020-04-23 03:29:52 +02:00
|
|
|
});
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-insertCSS", (id, isBrowserWindow, path) => {
|
2021-04-26 12:41:14 -04:00
|
|
|
if (isBrowserWindow) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
if (browserWindow) {
|
2025-11-14 17:38:55 +01:00
|
|
|
browserWindow.webContents.insertCSS(fs.readFileSync(path, "utf8"));
|
2021-04-26 12:41:14 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2025-11-14 17:38:55 +01:00
|
|
|
const browserViews = (global["browserViews"] =
|
|
|
|
|
global["browserViews"] || []);
|
2021-04-26 12:41:14 -04:00
|
|
|
let view = null;
|
|
|
|
|
for (let i = 0; i < browserViews.length; i++) {
|
2025-11-14 17:38:55 +01:00
|
|
|
if (browserViews[i]["id"] + 1000 === id) {
|
2021-04-26 12:41:14 -04:00
|
|
|
view = browserViews[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (view) {
|
2025-11-14 17:38:55 +01:00
|
|
|
view.webContents.insertCSS(fs.readFileSync(path, "utf8"));
|
2021-04-26 12:41:14 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-getAllExtensions", (id) => {
|
2021-07-02 02:04:23 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const extensionsList = browserWindow.webContents.session.getAllExtensions();
|
|
|
|
|
const chromeExtensionInfo = [];
|
2023-03-24 01:50:13 +01:00
|
|
|
Object.keys(extensionsList).forEach((key) => {
|
2021-07-02 02:04:23 +02:00
|
|
|
chromeExtensionInfo.push(extensionsList[key]);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-getAllExtensions-completed", chromeExtensionInfo);
|
2021-07-02 02:04:23 +02:00
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-removeExtension", (id, name) => {
|
2021-07-02 02:04:23 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.session.removeExtension(name);
|
|
|
|
|
});
|
2025-11-14 17:38:55 +01:00
|
|
|
socket.on("webContents-session-loadExtension", async (id, path, allowFileAccess = false) => {
|
2021-07-02 02:04:23 +02:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const extension = await browserWindow.webContents.session.loadExtension(path, { allowFileAccess: allowFileAccess });
|
2025-11-14 17:38:55 +01:00
|
|
|
electronSocket.emit("webContents-session-loadExtension-completed", extension);
|
2021-07-02 02:04:23 +02:00
|
|
|
});
|
2026-02-04 11:26:06 +01:00
|
|
|
socket.on("webContents-getZoomFactor", (id) => {
|
2025-12-04 17:52:01 +00:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const text = browserWindow.webContents.getZoomFactor();
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-getZoomFactor-completed", text);
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
2026-02-04 11:26:06 +01:00
|
|
|
socket.on("webContents-setZoomFactor", (id, factor) => {
|
2025-12-04 17:52:01 +00:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.setZoomFactor(factor);
|
|
|
|
|
});
|
2026-02-04 11:26:06 +01:00
|
|
|
socket.on("webContents-getZoomLevel", (id) => {
|
2025-12-04 17:52:01 +00:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
const content = browserWindow.webContents.getZoomLevel();
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-getZoomLevel-completed", content);
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
2026-02-04 11:26:06 +01:00
|
|
|
socket.on("webContents-setZoomLevel", (id, level) => {
|
2025-12-04 17:52:01 +00:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
browserWindow.webContents.setZoomLevel(level);
|
|
|
|
|
});
|
2026-02-04 11:26:06 +01:00
|
|
|
socket.on("webContents-setVisualZoomLevelLimits", async (id, minimumLevel, maximumLevel) => {
|
2025-12-04 17:52:01 +00:00
|
|
|
const browserWindow = getWindowById(id);
|
|
|
|
|
await browserWindow.webContents.setVisualZoomLevelLimits(minimumLevel, maximumLevel);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-setVisualZoomLevelLimits-completed");
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-toggleDevTools", (id) => {
|
|
|
|
|
getWindowById(id).webContents.toggleDevTools();
|
|
|
|
|
});
|
|
|
|
|
socket.on("webContents-closeDevTools", (id) => {
|
|
|
|
|
getWindowById(id).webContents.closeDevTools();
|
|
|
|
|
});
|
|
|
|
|
socket.on("webContents-isDevToolsOpened", function (id) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-isDevToolsOpened-completed", browserWindow.webContents.isDevToolsOpened());
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-isDevToolsFocused", function (id) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-isDevToolsFocused-completed", browserWindow.webContents.isDevToolsFocused());
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-setAudioMuted", (id, muted) => {
|
|
|
|
|
getWindowById(id).webContents.setAudioMuted(muted);
|
|
|
|
|
});
|
|
|
|
|
socket.on("webContents-isAudioMuted", function (id) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-isAudioMuted-completed", browserWindow.webContents.isAudioMuted());
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-isCurrentlyAudible", function (id) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-isCurrentlyAudible-completed", browserWindow.webContents.isCurrentlyAudible());
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-getUserAgent", function (id) {
|
|
|
|
|
const browserWindow = getWindowById(id);
|
2026-02-04 11:26:06 +01:00
|
|
|
electronSocket.emit("webContents-getUserAgent-completed", browserWindow.webContents.getUserAgent());
|
2025-12-04 17:52:01 +00:00
|
|
|
});
|
|
|
|
|
socket.on("webContents-setUserAgent", (id, userAgent) => {
|
|
|
|
|
getWindowById(id).webContents.setUserAgent(userAgent);
|
|
|
|
|
});
|
2017-10-21 04:37:01 +02:00
|
|
|
function getWindowById(id) {
|
2020-04-23 03:29:52 +02:00
|
|
|
if (id >= 1000) {
|
2023-03-23 14:02:46 +01:00
|
|
|
return (0, browserView_1.browserViewMediateService)(id - 1000);
|
2020-04-23 03:29:52 +02:00
|
|
|
}
|
2017-10-21 04:37:01 +02:00
|
|
|
return electron_1.BrowserWindow.fromId(id);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//# sourceMappingURL=webContents.js.map
|