2016-09-26 20:40:45 +00:00
|
|
|
(function () {
|
2020-03-20 20:28:31 +00:00
|
|
|
const { setImmediate } = require('timers');
|
|
|
|
const { ipcRenderer } = require('electron');
|
|
|
|
window.ipcRenderer = ipcRenderer;
|
|
|
|
window.setImmediate = setImmediate;
|
|
|
|
window.require = require;
|
2019-03-01 06:24:18 +00:00
|
|
|
|
|
|
|
function invoke (code) {
|
|
|
|
try {
|
2020-03-20 20:28:31 +00:00
|
|
|
return code();
|
2019-03-01 06:24:18 +00:00
|
|
|
} catch {
|
2020-03-20 20:28:31 +00:00
|
|
|
return null;
|
2019-03-01 06:24:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-04 18:35:06 +00:00
|
|
|
process.once('loaded', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
ipcRenderer.send('process-loaded');
|
|
|
|
});
|
2019-04-04 18:35:06 +00:00
|
|
|
|
2016-09-26 20:40:45 +00:00
|
|
|
if (location.protocol === 'file:') {
|
2020-03-20 20:28:31 +00:00
|
|
|
window.test = 'preload';
|
|
|
|
window.process = process;
|
2018-03-14 03:01:40 +00:00
|
|
|
if (process.env.sandboxmain) {
|
2018-07-30 01:13:42 +00:00
|
|
|
window.test = {
|
2019-03-01 06:24:18 +00:00
|
|
|
osSandbox: !process.argv.includes('--no-sandbox'),
|
|
|
|
hasCrash: typeof process.crash === 'function',
|
|
|
|
hasHang: typeof process.hang === 'function',
|
|
|
|
creationTime: invoke(() => process.getCreationTime()),
|
|
|
|
heapStatistics: invoke(() => process.getHeapStatistics()),
|
2019-05-30 09:50:35 +00:00
|
|
|
blinkMemoryInfo: invoke(() => process.getBlinkMemoryInfo()),
|
2019-10-09 17:59:08 +00:00
|
|
|
processMemoryInfo: invoke(() => process.getProcessMemoryInfo() ? {} : null),
|
2019-03-01 06:24:18 +00:00
|
|
|
systemMemoryInfo: invoke(() => process.getSystemMemoryInfo()),
|
|
|
|
systemVersion: invoke(() => process.getSystemVersion()),
|
|
|
|
cpuUsage: invoke(() => process.getCPUUsage()),
|
|
|
|
ioCounters: invoke(() => process.getIOCounters()),
|
2020-11-30 07:49:18 +00:00
|
|
|
uptime: invoke(() => process.uptime()),
|
2018-07-30 01:13:42 +00:00
|
|
|
env: process.env,
|
|
|
|
execPath: process.execPath,
|
2018-08-21 18:05:45 +00:00
|
|
|
pid: process.pid,
|
|
|
|
arch: process.arch,
|
|
|
|
platform: process.platform,
|
|
|
|
sandboxed: process.sandboxed,
|
2021-03-18 21:00:19 +00:00
|
|
|
contextIsolated: process.contextIsolated,
|
2018-08-21 18:05:45 +00:00
|
|
|
type: process.type,
|
|
|
|
version: process.version,
|
2021-03-17 18:23:03 +00:00
|
|
|
versions: process.versions,
|
|
|
|
contextId: process.contextId
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2018-03-14 03:01:40 +00:00
|
|
|
}
|
2016-09-26 20:40:45 +00:00
|
|
|
} else if (location.href !== 'about:blank') {
|
|
|
|
addEventListener('DOMContentLoaded', () => {
|
2018-12-05 08:03:39 +00:00
|
|
|
ipcRenderer.on('touch-the-opener', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
let errorMessage = null;
|
2018-12-05 08:03:39 +00:00
|
|
|
try {
|
2020-03-20 20:28:31 +00:00
|
|
|
const openerDoc = opener.document; // eslint-disable-line no-unused-vars
|
2018-12-05 08:03:39 +00:00
|
|
|
} catch (error) {
|
2020-03-20 20:28:31 +00:00
|
|
|
errorMessage = error.message;
|
2018-12-05 08:03:39 +00:00
|
|
|
}
|
2020-03-20 20:28:31 +00:00
|
|
|
ipcRenderer.send('answer', errorMessage);
|
|
|
|
});
|
|
|
|
ipcRenderer.send('child-loaded', window.opener == null, document.body.innerHTML, location.href);
|
|
|
|
});
|
2016-09-26 20:40:45 +00:00
|
|
|
}
|
2020-03-20 20:28:31 +00:00
|
|
|
})();
|