-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
138 additions
and
196,791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,8 @@ | ||
import { BrowserWindow, shell, ipcMain } from 'electron'; | ||
import { join } from 'path'; | ||
import * as Config from './utils/Config'; | ||
import * as DiscordWebSocket from './utils/DiscordWebSocket'; | ||
import { win } from './utils/Window'; | ||
|
||
export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
export async function prompt(message: string, app: Electron.App, options?: { | ||
closable?: boolean | ||
}) { | ||
const win = new BrowserWindow({ | ||
resizable: false, | ||
minimizable: false, | ||
maximizable: false, | ||
closable: typeof options?.closable !== 'undefined' ? options?.closable : true, | ||
webPreferences: { | ||
preload: join(__dirname, 'prompt.js') | ||
} | ||
}); | ||
|
||
ipcMain.on('autocomplete-token', async () => { | ||
if (Config.get(app, 'discord_token')) { | ||
await runJs(`document.querySelector('input#discord-token').value = '${Config.get(app, 'discord_token')}'`); | ||
} | ||
}); | ||
|
||
ipcMain.on('token-received', async (e, data) => { | ||
Config.set(app, 'discord_token', data); | ||
Config.set(app, 'use_listening_to', true); | ||
win.close(); | ||
DiscordWebSocket.connect(data, app).catch(console.error); | ||
}); | ||
|
||
win.webContents.setWindowOpenHandler((details) => { | ||
shell.openExternal(details.url); | ||
return { action: 'deny' }; | ||
}); | ||
win.setMenuBarVisibility(false); | ||
await win.loadFile(join(__dirname, 'prompt.html'), { hash: message }); | ||
} | ||
|
||
export async function runJs(code: string) { | ||
// return code; | ||
return win.webContents.executeJavaScript(code); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.