Skip to content

Instantly share code, notes, and snippets.

@nornagon
Last active July 8, 2021 23:09
Show Gist options
  • Save nornagon/c98992fbd090d8fbaf9077e30db6d846 to your computer and use it in GitHub Desktop.
Save nornagon/c98992fbd090d8fbaf9077e30db6d846 to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
<!-- Empty -->
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
</head>
<body>
<!-- note: this is just a random test pdf.
the test behaves the same with local files, but gist.github.com doesn't seem to like to store pdf files -->
<embed src="https://www.pickupstix.com/assets/media/locations/pdf/empty.pdf" style="width:100%;height:400px">
</body>
</html>
const { app, BrowserWindow, session } = require('electron');
const { join } = require('path');
// uncomment this line to break the PDF Viewer
app.commandLine.appendSwitch('disable-site-isolation-trials');
async function ready() {
const mainWindow = new BrowserWindow({
x: 0,
y: 0,
width: 800,
height: 800,
show: true,
});
mainWindow.loadURL(join("file://", __dirname, "main.html"));
}
app.whenReady().then(ready);
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment