electron.ipcMain.on("LIGHTCORD_SET_ALWAYS_ON_TOP", (event, enabled) => { if(typeof enabled !== "boolean")throw new TypeError("Incorrect value: enabled should be typeof boolean.") const window = electron.BrowserWindow.fromId(getMainWindowId()) if(!window)return window.setAlwaysOnTop(enabled) })
function openDevTools(_win) { const win = _win || electron.BrowserWindow.getFocusedWindow(); if (win) { if (win.webContents.isDevToolsOpened()) { win.webContents.closeDevTools(); } win.webContents.openDevTools(); } }
function hookRenderers(flag) { if (is.main) { global[defaultsNameSpace].shouldHookConsole = flag; for (const win of electron.BrowserWindow.getAllWindows()) { win.webContents.send(updateChannel, flag); } } }
function setAppBadge(count) { const win = _electron.BrowserWindow.fromId((0, _mainScreen.getMainWindowId)()); const { index, description } = getOverlayIconData(count); // Prevent setting a new icon when the icon is the same if (lastIndex !== index) { if (index == null) { win.setOverlayIcon(null, description); } else { win.setOverlayIcon(appIcons[index], description); } lastIndex = index; } }
function getWindow() { let window = _electron.BrowserWindow.getFocusedWindow(); if (!window) { const windowList = _electron.BrowserWindow.getAllWindows(); if (windowList && windowList[0]) { window = windowList[0]; window.show(); window.focus(); } } return window; }
electron.ipcMain.on("LIGHTCORD_GET_WEBCONTENTS_ID", (event) => { event.returnValue = electron.BrowserWindow.fromId(getMainWindowId()).webContents.id })
events.on("ready", () => { const browserWindow = electron.BrowserWindow.fromId(getMainWindowId()) const webContents = browserWindow.webContents webContents.on("devtools-opened", () => { webContents.send("LIGHTCORD_DEVTOOLS_OPEN") }) })
function sendToAllWindows(channel) { electron.BrowserWindow.getAllWindows().forEach(win => { const contents = win.webContents; if (contents != null) { contents.send(channel); } }); }
electron.ipcMain.on("LIGHTCORD_SET_USER_AGENT", (event, ua) => { const browserWindow = electron.BrowserWindow.fromId(getMainWindowId()) browserWindow.webContents.userAgent = ua event.returnValue = null })
electron.ipcMain.on("LIGHTCORD_GET_IS_DEVTOOLS_OPEN", (event) => { event.returnValue = electron.BrowserWindow.fromId(getMainWindowId()).webContents.isDevToolsOpened() })
electron.ipcMain.on("LIGHTCORD_SET_ALWAYS_ON_TOP", (event, enabled) => { if(typeof enabled !== "boolean")throw new TypeError("Incorrect value: enabled should be typeof boolean.") const window = electron.BrowserWindow.fromId(getMainWindowId()) if(!window)return window.setAlwaysOnTop(enabled) })
function getWindow() { let window = _electron.BrowserWindow.getFocusedWindow(); if (!window) { const windowList = _electron.BrowserWindow.getAllWindows(); if (windowList && windowList[0]) { window = windowList[0]; window.show(); window.focus(); } } return window; }
electron.ipcMain.on("LIGHTCORD_GET_WEBCONTENTS_ID", (event) => { event.returnValue = electron.BrowserWindow.fromId(getMainWindowId()).webContents.id })
function sendToAllWindows(channel) { electron.BrowserWindow.getAllWindows().forEach(win => { const contents = win.webContents; if (contents != null) { contents.send(channel); } }); }
electron.ipcMain.on("LIGHTCORD_SET_USER_AGENT", (event, ua) => { const browserWindow = electron.BrowserWindow.fromId(getMainWindowId()) browserWindow.webContents.userAgent = ua event.returnValue = null })