summaryrefslogtreecommitdiff
path: root/main.js
blob: 0b61b05af0e695d9f7750f1bdcb8469524b6671c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');

function createWindow () {
    const win = new BrowserWindow({
        width: 1220,
        minWidth: 150,
        icon: require('os').platform() === "darwin" ? "icon.icns" : "icon.png",
        minHeight: 100,
        trafficLightPosition: {
            x: 26,
            y: 24
        },
        title: "Plex",
        autoHideMenuBar: true,
        backgroundColor: "#3c434b",
        darkTheme: true,
        titleBarStyle: "hiddenInset",
        tabbingIdentifier: "main",
        titleBarOverlay: true,
        height: 720,
        webPreferences: {
            nodeIntegration: false,
            nodeIntegrationInWorker: false,
            nodeIntegrationInSubFrames: false,
            imageAnimationPolicy: "noAnimation",
            webgl: false,
            plugins: false,
            experimentalFeatures: false,
            scrollBounce: true,
            sandbox: false,
            contextIsolation: false,
            safeDialogs: true,
            autoplayPolicy: "no-user-gesture-required",
            spellcheck: true,
            enableWebSQL: false,
            preload: path.join(__dirname, 'preload.js')
        }
    })

    win.loadURL('https://plex.equestria.dev');
    win.on("enter-full-screen", () => {
        win.send("traffic-lights-off");
    });
    win.on("leave-full-screen", () => {
        win.send("traffic-lights-on");
    });
    win.on("enter-html-full-screen", () => {
        win.send("traffic-lights-off");
    });
    win.on("leave-html-full-screen", () => {
        win.send("traffic-lights-on");
    });

    ipcMain.on("resize-to-match", (_, args) => {
        if (args > 0) {
            win.setSize(win.getSize()[0], args, true);
            win.send("resize-normal");
        }
    })

    win.on('resize', ()=> {
        win.send("resize");
    });
}

app.whenReady().then(() => {
    createWindow();

    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) {
            createWindow();
        }
    });
});

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});