mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	Add DuckDuckGo search
This commit is contained in:
		
							parent
							
								
									5c109f530b
								
							
						
					
					
						commit
						8454a6d579
					
				
					 5 changed files with 45 additions and 2198 deletions
				
			
		|  | @ -1,8 +1,9 @@ | |||
| import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron"; | ||||
| import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation, getLangName} from "../utils"; | ||||
| import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation, getLangName, sleep} from "../utils"; | ||||
| import path from "path"; | ||||
| import os from "os"; | ||||
| import fs from "fs"; | ||||
| import {mainWindow} from "../window"; | ||||
| var settingsWindow: BrowserWindow; | ||||
| var instance: number = 0; | ||||
| const userDataPath = app.getPath("userData"); | ||||
|  | @ -37,19 +38,42 @@ export function createSettingsWindow() { | |||
|                 settingsWindow.loadURL(`file://${__dirname}/settings.html`); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         const userDataPath = app.getPath("userData"); | ||||
|         const themesFolder = userDataPath + "/themes/"; | ||||
|         if (!fs.existsSync(themesFolder)) { | ||||
|             fs.mkdirSync(themesFolder); | ||||
|             console.log("Created missing theme folder"); | ||||
|         } | ||||
|         settingsWindow.webContents.on("did-finish-load", () => { | ||||
|             fs.readdirSync(themesFolder).forEach((file) => { | ||||
|                 try { | ||||
|                     const manifest = fs.readFileSync(`${themesFolder}/${file}/manifest.json`, "utf8"); | ||||
|                     var themeFile = JSON.parse(manifest); | ||||
|                     settingsWindow.webContents.send( | ||||
|                         "themeLoader", | ||||
|                         fs.readFileSync(`${themesFolder}/${file}/${themeFile.theme}`, "utf-8") | ||||
|                     ); | ||||
|                     console.log(`%cLoaded ${themeFile.name} made by ${themeFile.author}`, "color:red"); | ||||
|                 } catch (err) { | ||||
|                     console.error(err); | ||||
|                 } | ||||
|             }); | ||||
|         }); | ||||
|         ipcMain.on("saveSettings", (event, args: Settings) => { | ||||
|             console.log(args); | ||||
|             setConfigBulk(args); | ||||
|         }); | ||||
|         ipcMain.on("openStorageFolder", (event) => { | ||||
|         ipcMain.on("openStorageFolder", async (event) => { | ||||
|             shell.openPath(storagePath); | ||||
|             await sleep(1000); | ||||
|         }); | ||||
|         ipcMain.on("openThemesFolder", (event) => { | ||||
|         ipcMain.on("openThemesFolder", async (event) => { | ||||
|             shell.openPath(themesPath); | ||||
|             await sleep(1000); | ||||
|         }); | ||||
|         ipcMain.on("openPluginsFolder", (event) => { | ||||
|         ipcMain.on("openPluginsFolder", async (event) => { | ||||
|             shell.openPath(pluginsPath); | ||||
|             await sleep(1000); | ||||
|         }); | ||||
|         ipcMain.on("getLangName", async (event) => { | ||||
|             event.returnValue = await getLangName(); | ||||
|  |  | |||
|  | @ -26,3 +26,6 @@ if (ipcRenderer.sendSync("getLangName") == "en-US") { | |||
|         addStyle(fs.readFileSync(cssPath, "utf8")); | ||||
|     }); | ||||
| } | ||||
| ipcRenderer.on("themeLoader", (event, message) => { | ||||
|     addStyle(message); | ||||
| }); | ||||
|  |  | |||
|  | @ -99,7 +99,7 @@ | |||
|                 <option value="stable">Stable</option> | ||||
|                 <option value="canary">Canary</option> | ||||
|                 <option value="ptb">PTB</option> | ||||
|                 <option value="hummus">Hummus (unofficial)</option> | ||||
|                 <option value="hummus">Hummus (unofficial, experimental)</option> | ||||
|             </select> | ||||
|             <div> | ||||
|                 <p class="header" id="settings-channel">Discord channel</p> | ||||
|  |  | |||
|  | @ -23,17 +23,17 @@ import {tray} from "./tray"; | |||
| import {iconPath} from "./main"; | ||||
| export let mainWindow: BrowserWindow; | ||||
| export let inviteWindow: BrowserWindow; | ||||
| var osType = os.type(); | ||||
| 
 | ||||
| var osType = os.type(); | ||||
| contextMenu({ | ||||
|     showSaveImageAs: true, | ||||
|     showCopyImageAddress: true, | ||||
|     showSearchWithGoogle: true | ||||
|     showSearchWithGoogle: true, | ||||
|     showSearchWithDuckDuckGo: true | ||||
| }); | ||||
| 
 | ||||
| async function doAfterDefiningTheWindow() { | ||||
|     var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning"); | ||||
|     checkIfConfigIsBroken(); | ||||
|     await checkIfConfigIsBroken(); | ||||
|     registerIpc(); | ||||
|     if (await getConfig("mobileMode")) { | ||||
|         mainWindow.webContents.userAgent = | ||||
|  | @ -104,7 +104,6 @@ async function doAfterDefiningTheWindow() { | |||
|                 } | ||||
|                 getFavicon() | ||||
|             `)
 | ||||
|             console.log(app.getPath("temp")) | ||||
|             var buf = new Buffer(faviconBase64.replace(/^data:image\/\w+;base64,/, ""), 'base64'); | ||||
|             fs.writeFileSync(path.join(app.getPath("temp"), "/", "tray.png"), buf, "utf-8"); | ||||
|             let trayPath = nativeImage.createFromPath(path.join(app.getPath("temp"), "/", "tray.png")); | ||||
|  | @ -133,10 +132,10 @@ async function doAfterDefiningTheWindow() { | |||
|             } | ||||
|         }); | ||||
|     }); | ||||
|     setMenu(); | ||||
|     await setMenu(); | ||||
|     mainWindow.on("close", async (e) => { | ||||
|         let [width, height] = mainWindow.getSize(); | ||||
|         setWindowState({ | ||||
|         await setWindowState({ | ||||
|             width: width, | ||||
|             height: height, | ||||
|             isMaximized: mainWindow.isMaximized() | ||||
|  | @ -175,22 +174,22 @@ async function doAfterDefiningTheWindow() { | |||
|         if ((await getConfig("skipSplash")) == true) { | ||||
|             switch (await getConfig("channel")) { | ||||
|                 case "stable": | ||||
|                     mainWindow.loadURL("https://discord.com/app"); | ||||
|                     await mainWindow.loadURL("https://discord.com/app"); | ||||
|                     break; | ||||
|                 case "canary": | ||||
|                     mainWindow.loadURL("https://canary.discord.com/app"); | ||||
|                     await mainWindow.loadURL("https://canary.discord.com/app"); | ||||
|                     break; | ||||
|                 case "ptb": | ||||
|                     mainWindow.loadURL("https://ptb.discord.com/app"); | ||||
|                     await mainWindow.loadURL("https://ptb.discord.com/app"); | ||||
|                     break; | ||||
|                 case "hummus": | ||||
|                     mainWindow.loadURL("https://hummus.sys42.net/"); | ||||
|                     await mainWindow.loadURL("https://hummus.sys42.net/"); | ||||
|                     break; | ||||
|                 case undefined: | ||||
|                     mainWindow.loadURL("https://discord.com/app"); | ||||
|                     await mainWindow.loadURL("https://discord.com/app"); | ||||
|                     break; | ||||
|                 default: | ||||
|                     mainWindow.loadURL("https://discord.com/app"); | ||||
|                     await mainWindow.loadURL("https://discord.com/app"); | ||||
|             } | ||||
|         } else { | ||||
|             await mainWindow.loadFile(path.join(__dirname, "/content/splash.html")); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue