aboutsummaryrefslogtreecommitdiff
path: root/index.js
blob: 69af246dd077ea1be649fee299596116aae65900 (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Alaska Client: Copyright (c) 2025 Andrew Lee

const { app, BrowserWindow, dialog, globalShortcut } = require('electron');
const path = require('path');
const fs = require('fs');
const { autoUpdater } = require("electron-updater");
const log = require('electron-log');
const conf = require('./config.json');

autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';

const pluginPaths = {
  win32: path.join(app.getAppPath(), 'plugin/pepflashplayer.dll'),
  darwin: path.join(app.getAppPath(), 'plugin/PepperFlashPlayer.plugin'),
  linux: path.join(app.getAppPath(), 'plugin/libpepflashplayer.so')
};

const pluginName = pluginPaths[process.platform];

if (process.platform === 'linux') app.commandLine.appendSwitch('--no-sandbox');
app.commandLine.appendSwitch('ignore-certificate-errors');

if (process.mainModule.filename.includes('app.asar')) {
  const unpackedPath = pluginName.replace('app.asar', 'app.asar.unpacked');
  console.log(`Adjusted plugin path for asar: ${unpackedPath}`);
  app.commandLine.appendSwitch('ppapi-flash-path', unpackedPath);
} else {
  app.commandLine.appendSwitch('ppapi-flash-path', pluginName);
}

app.commandLine.appendSwitch('ppapi-flash-version', '31.0.0.122');

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


app.on('ready', function() {
  autoUpdater.checkForUpdatesAndNotify();
});

app.whenReady().then(() => {
  const win = new BrowserWindow({
    width: conf.window.width,
    height: conf.window.height,
    autoHideMenuBar: true,
    webPreferences: {
      plugins: true
    }

  });

  const ses = win.webContents.session;
  
  win.loadURL(conf.url);

  globalShortcut.register("CTRL+SHIFT+F10", () => {
    let dir = app.getPath('userData');
     // Show a confirmation dialog
    const response = dialog.showMessageBoxSync({
      type: 'warning',
      buttons: ['Yes', 'No'],
      defaultId: 1, // Default to "No"
      title: 'Confirm Deletion',
      message: 'Are you sure you want to delete the "Pepper Data" directory?',
      detail: 'This action cannot be undone.',
    });

    if (response === 0) { // "Yes" button index
      try {
        fs.rmdirSync(`${dir}/Pepper Data`, { recursive: true });
        app.relaunch();
        app.exit();
      } catch (err) {
        console.error('Error deleting directory:', err);
      }
    }
  });

  globalShortcut.register("CTRL+SHIFT+I", () => {
    win.webContents.openDevTools();
	});

  globalShortcut.register("CTRL+R", () => {
    win.webContents.reload();
	});

  globalShortcut.register("CTRL+SHIFT+R", () => {
    ses.clearCache();
    win.webContents.reload();
	});


})

autoUpdater.on('checking-for-update', () => {
  console.log('Checking for updates...');
});

autoUpdater.on('update-available', () => {
  console.log('Update available.');
});

autoUpdater.on('error', (err) => {
  console.log('Error in auto-updater. ' + err);
});

autoUpdater.on('download-progress', (progressObj) => {
  let log_message = "Download speed: " + progressObj.bytesPerSecond;
  log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
  log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
  console.log(log_message);
});

autoUpdater.on('update-downloaded', (info) => {
  console.log('Update downloaded');
});