This repository has been archived by the owner on Aug 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
98 lines (66 loc) · 2.78 KB
/
app.js
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
const EventHooker = require("./modules/EventHooker")
// IMPORT SETTINGS MANAGER AND APPLY SETTINGS WITH DEFAULT SETTINGS
const SettingsManager = require('./modules/SettingsManager')
SettingsManager.apply()
// IMPORT CHERRY PICKED CONSTANTS FROM LIBRARIES
const { app, BrowserWindow, ipcMain, BrowserView, Menu, dialog, Notification, session } = require('electron')
const { ElectronBlocker } = require('@cliqz/adblocker-electron')
const { shell } = require('electron/common')
// IMPORT WHOLE REQUIRED LIBRARIES
const fsys = require('./modules/FileSystem')
const axios = require('axios').default
const path = require("path")
const fs = require("fs")
const fetch = require("node-fetch")
const appInfo = require("./modules/AppInfo")
const discordRpc = require('./modules/DiscordRichPresence').initalize()
require("./modules/SquirrelPatch")(app)
var error_counts=0
app.whenReady().then(() => {
(async () => {
const win = new BrowserWindow({
width: 1000,
height: 800,
show: false,
webPreferences: {
autoplayPolicy: false,
webSecurity: false,
nodeIntegration: true,
preload: path.join(app.getAppPath(), "src", "js", "preload.js"),
},
autoHideMenuBar: true
})
require("./modules/EventHooker").register_wc(app, win)
if (process.argv.includes("devtools")) {
win.webContents.openDevTools()
}
const Logger = require("./modules/Logger").setup();
ipcMain.on("loadSettings", () => {
win.webContents.send("loadSettings", SettingsManager.get());
});
win.once("ready-to-show", () => {
win.show();
require("./modules/HighwayPatrol")()
require("./modules/AdBlocker")(session.defaultSession)
app.setAppUserModelId("life.koda.ytmusic");
Logger.out("User model id set: life.koda.ytmusic");
Logger.out("Successfully initiailized!")
ipcMain.on("injectReady", () => {
win.webContents.send("inject", {settings: `file://${__dirname}/src/settings.html`, error: `file://${__dirname}/src/error.html`});
});
ipcMain.on("saveSettings", SettingsManager.save);
discordRpc.set_presence({
state: "🔃 Connecting to YT Music...",
largeImageKey: 'icon_512',
instance: true,
});
require("./modules/UpdateChecker")(win)
ipcMain.on("asynchronous-message", discordRpc.event_route);
})
win.loadURL(`file://${__dirname}/src/splash.html`)
win.once("close", e => {
win.webContents.send("signal-quit", {});
e.preventDefault(false)
})
})()
})