mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	formatting
a.k.a. "Install Prettier"
This commit is contained in:
		
							parent
							
								
									18bebfb421
								
							
						
					
					
						commit
						87920505db
					
				
					 32 changed files with 1382 additions and 1341 deletions
				
			
		
							
								
								
									
										1
									
								
								.husky/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.husky/.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | _ | ||||||
							
								
								
									
										5
									
								
								.husky/pre-commit
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								.husky/pre-commit
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | #!/bin/sh | ||||||
|  | . "$(dirname $0)/_/husky.sh" | ||||||
|  | 
 | ||||||
|  | npm run format | ||||||
|  | git add -A | ||||||
							
								
								
									
										11
									
								
								.prettierignore
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.prettierignore
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | ||||||
|  | # Some prettier-specific files so it doesn't die. | ||||||
|  | **/*.png | ||||||
|  | **/*.ico | ||||||
|  | LICENSE | ||||||
|  | .gitignore | ||||||
|  | 
 | ||||||
|  | node_modules | ||||||
|  | out/ | ||||||
|  | dist | ||||||
|  | ts-out/ | ||||||
|  | ts-out | ||||||
							
								
								
									
										46
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										46
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -1,12 +1,13 @@ | ||||||
| { | { | ||||||
|   "name": "ArmCord", |   "name": "ArmCord", | ||||||
|   "version": "3.0.4", |   "version": "3.1.0", | ||||||
|   "lockfileVersion": 2, |   "lockfileVersion": 2, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "ArmCord", |       "name": "ArmCord", | ||||||
|       "version": "3.0.4", |       "version": "3.1.0", | ||||||
|  |       "hasInstallScript": true, | ||||||
|       "license": "OSL-3.0", |       "license": "OSL-3.0", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "electron-context-menu": "^3.1.2", |         "electron-context-menu": "^3.1.2", | ||||||
|  | @ -21,6 +22,8 @@ | ||||||
|         "copyfiles": "^2.4.1", |         "copyfiles": "^2.4.1", | ||||||
|         "electron": "^17.1.0", |         "electron": "^17.1.0", | ||||||
|         "electron-builder": "^22.14.13", |         "electron-builder": "^22.14.13", | ||||||
|  |         "husky": "^7.0.4", | ||||||
|  |         "prettier": "^2.5.1", | ||||||
|         "typescript": "^4.5.4" |         "typescript": "^4.5.4" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  | @ -2020,6 +2023,21 @@ | ||||||
|         "node": ">= 6" |         "node": ">= 6" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/husky": { | ||||||
|  |       "version": "7.0.4", | ||||||
|  |       "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", | ||||||
|  |       "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", | ||||||
|  |       "dev": true, | ||||||
|  |       "bin": { | ||||||
|  |         "husky": "lib/bin.js" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=12" | ||||||
|  |       }, | ||||||
|  |       "funding": { | ||||||
|  |         "url": "https://github.com/sponsors/typicode" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/iconv-corefoundation": { |     "node_modules/iconv-corefoundation": { | ||||||
|       "version": "1.1.7", |       "version": "1.1.7", | ||||||
|       "resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", |       "resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", | ||||||
|  | @ -2724,6 +2742,18 @@ | ||||||
|         "node": ">=4" |         "node": ">=4" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/prettier": { | ||||||
|  |       "version": "2.5.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", | ||||||
|  |       "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", | ||||||
|  |       "dev": true, | ||||||
|  |       "bin": { | ||||||
|  |         "prettier": "bin-prettier.js" | ||||||
|  |       }, | ||||||
|  |       "engines": { | ||||||
|  |         "node": ">=10.13.0" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/process-nextick-args": { |     "node_modules/process-nextick-args": { | ||||||
|       "version": "2.0.1", |       "version": "2.0.1", | ||||||
|       "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", |       "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", | ||||||
|  | @ -5191,6 +5221,12 @@ | ||||||
|         "debug": "4" |         "debug": "4" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "husky": { | ||||||
|  |       "version": "7.0.4", | ||||||
|  |       "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.4.tgz", | ||||||
|  |       "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", | ||||||
|  |       "dev": true | ||||||
|  |     }, | ||||||
|     "iconv-corefoundation": { |     "iconv-corefoundation": { | ||||||
|       "version": "1.1.7", |       "version": "1.1.7", | ||||||
|       "resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", |       "resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", | ||||||
|  | @ -5728,6 +5764,12 @@ | ||||||
|       "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", |       "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|  |     "prettier": { | ||||||
|  |       "version": "2.5.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", | ||||||
|  |       "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", | ||||||
|  |       "dev": true | ||||||
|  |     }, | ||||||
|     "process-nextick-args": { |     "process-nextick-args": { | ||||||
|       "version": "2.0.1", |       "version": "2.0.1", | ||||||
|       "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", |       "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", | ||||||
|  |  | ||||||
|  | @ -7,7 +7,9 @@ | ||||||
|     "build": "tsc && copyfiles -u 1 src/**/*.html src/**/**/*.css ts-out/ && copyfiles package.json ts-out/ && copyfiles assets/** ts-out/", |     "build": "tsc && copyfiles -u 1 src/**/*.html src/**/**/*.css ts-out/ && copyfiles package.json ts-out/ && copyfiles assets/** ts-out/", | ||||||
|     "watch": "tsc -w", |     "watch": "tsc -w", | ||||||
|     "start": "npm run build && electron ./ts-out/main.js", |     "start": "npm run build && electron ./ts-out/main.js", | ||||||
|     "package": "npm run build && electron-builder" |     "package": "npm run build && electron-builder", | ||||||
|  |     "format": "prettier --write **/*", | ||||||
|  |     "postinstall": "husky install" | ||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
|  | @ -25,6 +27,8 @@ | ||||||
|     "copyfiles": "^2.4.1", |     "copyfiles": "^2.4.1", | ||||||
|     "electron": "^17.1.0", |     "electron": "^17.1.0", | ||||||
|     "electron-builder": "^22.14.13", |     "electron-builder": "^22.14.13", | ||||||
|  |     "husky": "^7.0.4", | ||||||
|  |     "prettier": "^2.5.1", | ||||||
|     "typescript": "^4.5.4" |     "typescript": "^4.5.4" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								prettier.config.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								prettier.config.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | module.exports = { | ||||||
|  |     printWidth: 120, | ||||||
|  |     tabWidth: 4, | ||||||
|  |     useTabs: false, | ||||||
|  |     semi: true, | ||||||
|  |     singleQuote: false, | ||||||
|  |     quoteProps: "as-needed", | ||||||
|  |     jsxSingleQuote: false, | ||||||
|  |     trailingComma: "none", | ||||||
|  |     bracketSpacing: false, | ||||||
|  |     jsxBracketSameLine: false, | ||||||
|  |     arrowParens: "always", | ||||||
|  |     endOfLine: "auto" | ||||||
|  | }; | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| .info-3pQQBb:last-child:before { | .info-3pQQBb:last-child:before { | ||||||
|   content: "ArmCord Version: 3.1.0"!important; |     content: "ArmCord Version: 3.1.0" !important; | ||||||
|     height: auto; |     height: auto; | ||||||
|     line-height: 16px; |     line-height: 16px; | ||||||
|     text-align: center; |     text-align: center; | ||||||
|  |  | ||||||
|  | @ -2,10 +2,7 @@ | ||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
| <html lang="en"> | <html lang="en"> | ||||||
|     <head> |     <head> | ||||||
|     <link |         <link rel="stylesheet" href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css" /> | ||||||
|       rel="stylesheet" |  | ||||||
|       href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css" |  | ||||||
|     /> |  | ||||||
|         <meta charset="UTF-8" /> |         <meta charset="UTF-8" /> | ||||||
|         <title>ArmCord Setup</title> |         <title>ArmCord Setup</title> | ||||||
|         <style> |         <style> | ||||||
|  | @ -23,7 +20,6 @@ | ||||||
|             </div> |             </div> | ||||||
|         </div> |         </div> | ||||||
|         <script> |         <script> | ||||||
| 
 |  | ||||||
|             function fade(element) { |             function fade(element) { | ||||||
|                 var op = 1; // initial opacity |                 var op = 1; // initial opacity | ||||||
|                 var timer = setInterval(function () { |                 var timer = setInterval(function () { | ||||||
|  | @ -51,12 +47,12 @@ | ||||||
|                         automaticPatches: false, |                         automaticPatches: false, | ||||||
|                         mods: "cumcord", |                         mods: "cumcord", | ||||||
|                         blurType: "acrylic" |                         blurType: "acrylic" | ||||||
|           }) |                     }); | ||||||
|                     fade(document.getElementById("setup")); |                     fade(document.getElementById("setup")); | ||||||
|                     setTimeout(function () { |                     setTimeout(function () { | ||||||
|                   window.armcordinternal.restart() |                         window.armcordinternal.restart(); | ||||||
|                     }, 5000); |                     }, 5000); | ||||||
|         }) |                 }); | ||||||
|                 document.getElementById("full").addEventListener("click", function () { |                 document.getElementById("full").addEventListener("click", function () { | ||||||
|                     document.getElementById("setup").innerHTML = ` |                     document.getElementById("setup").innerHTML = ` | ||||||
|         <p class="text-center setup-ask">Choose your Discord channel/instance:</p> |         <p class="text-center setup-ask">Choose your Discord channel/instance:</p> | ||||||
|  | @ -77,9 +73,7 @@ | ||||||
|       </div> |       </div> | ||||||
|       <button id="next" class="center">Next</button> |       <button id="next" class="center">Next</button> | ||||||
|       `; |       `; | ||||||
|           document |                     document.getElementById("next").addEventListener("click", function () { | ||||||
|             .getElementById("next") |  | ||||||
|             .addEventListener("click", function () { |  | ||||||
|                         var branch = document.getElementById("channel").value; |                         var branch = document.getElementById("channel").value; | ||||||
|                         var csp = document.getElementById("csp").value; |                         var csp = document.getElementById("csp").value; | ||||||
|                         if (csp === "true") { |                         if (csp === "true") { | ||||||
|  | @ -95,9 +89,7 @@ | ||||||
|       <p>Why not all of them? Having many client mods at the same time can cause issues. If you really want to do it though, check our documentation ;)</p> |       <p>Why not all of them? Having many client mods at the same time can cause issues. If you really want to do it though, check our documentation ;)</p> | ||||||
|       <button id="next" class="center">Next</button> |       <button id="next" class="center">Next</button> | ||||||
|       `; |       `; | ||||||
|                 document |                             document.getElementById("next").addEventListener("click", function () { | ||||||
|                   .getElementById("next") |  | ||||||
|                   .addEventListener("click", function () { |  | ||||||
|                                 var mod = document.getElementById("mod").value; |                                 var mod = document.getElementById("mod").value; | ||||||
|                                 window.armcordinternal.saveSettings({ |                                 window.armcordinternal.saveSettings({ | ||||||
|                                     windowStyle: "default", |                                     windowStyle: "default", | ||||||
|  | @ -107,7 +99,7 @@ | ||||||
|                                     automaticPatches: false, |                                     automaticPatches: false, | ||||||
|                                     mods: mod, |                                     mods: mod, | ||||||
|                                     blurType: "acrylic" |                                     blurType: "acrylic" | ||||||
|                     }) |                                 }); | ||||||
|                                 fade(document.getElementById("setup")); |                                 fade(document.getElementById("setup")); | ||||||
|                                 setTimeout(function () { |                                 setTimeout(function () { | ||||||
|                                     window.armcordinternal.restart(); |                                     window.armcordinternal.restart(); | ||||||
|  | @ -122,10 +114,10 @@ | ||||||
|                                 automaticPatches: false, |                                 automaticPatches: false, | ||||||
|                                 mods: "none", |                                 mods: "none", | ||||||
|                                 blurType: "acrylic" |                                 blurType: "acrylic" | ||||||
|                 }) |                             }); | ||||||
|                             fade(document.getElementById("setup")); |                             fade(document.getElementById("setup")); | ||||||
|                             setTimeout(function () { |                             setTimeout(function () { | ||||||
|                   window.armcordinternal.restart() |                                 window.armcordinternal.restart(); | ||||||
|                             }, 5000); |                             }, 5000); | ||||||
|                         } |                         } | ||||||
|                     }); |                     }); | ||||||
|  |  | ||||||
|  | @ -11,10 +11,7 @@ | ||||||
|     <body> |     <body> | ||||||
|         <div class="container"> |         <div class="container"> | ||||||
|             <video autoplay loop class="logo" id="splashscreen-armcord"> |             <video autoplay loop class="logo" id="splashscreen-armcord"> | ||||||
|         <source |                 <source src="https://armcord.smartfridge.space/discord_loading.webm" type="video/webm" /> | ||||||
|           src="https://armcord.smartfridge.space/discord_loading.webm" |  | ||||||
|           type="video/webm" |  | ||||||
|         /> |  | ||||||
|             </video> |             </video> | ||||||
|             <p id="text-splashscreen"></p> |             <p id="text-splashscreen"></p> | ||||||
|         </div> |         </div> | ||||||
|  | @ -22,8 +19,7 @@ | ||||||
|     <script> |     <script> | ||||||
|         const text = document.getElementById("text-splashscreen"); |         const text = document.getElementById("text-splashscreen"); | ||||||
|         if (window.navigator.onLine === false) { |         if (window.navigator.onLine === false) { | ||||||
|       text.innerHTML = |             text.innerHTML = "You appear to be offline. Please connect to the internet and try again."; | ||||||
|         "You appear to be offline. Please connect to the internet and try again."; |  | ||||||
|         } else { |         } else { | ||||||
|             text.innerHTML = "Starting ArmCord..."; |             text.innerHTML = "Starting ArmCord..."; | ||||||
|             fetch("https://armcord.smartfridge.space/latest.json") |             fetch("https://armcord.smartfridge.space/latest.json") | ||||||
|  | @ -35,10 +31,9 @@ | ||||||
|                         elem.src = "https://armcord.smartfridge.space/update.webp"; |                         elem.src = "https://armcord.smartfridge.space/update.webp"; | ||||||
|                         document.body.prepend(elem); |                         document.body.prepend(elem); | ||||||
|                         document.getElementById("splashscreen-armcord").remove(); |                         document.getElementById("splashscreen-armcord").remove(); | ||||||
|             text.innerHTML = |                         text.innerHTML = "A new version of ArmCord is available. Please update to the latest version."; | ||||||
|               "A new version of ArmCord is available. Please update to the latest version."; |  | ||||||
|                     } else { |                     } else { | ||||||
|             console.log("ArmCord is up to date.") |                         console.log("ArmCord is up to date."); | ||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
|             setTimeout(() => { |             setTimeout(() => { | ||||||
|  |  | ||||||
|  | @ -12,8 +12,8 @@ import electron from "electron"; | ||||||
| import * as storage from "electron-json-storage"; | import * as storage from "electron-json-storage"; | ||||||
| const otherMods = { | const otherMods = { | ||||||
|     generic: { |     generic: { | ||||||
|     electronProxy: require("util").types.isProxy(electron), // Many modern mods overwrite electron with a proxy with a custom BrowserWindow (copied from PowerCord)
 |         electronProxy: require("util").types.isProxy(electron) // Many modern mods overwrite electron with a proxy with a custom BrowserWindow (copied from PowerCord)
 | ||||||
|   }, |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const unstrictCSP = () => { | const unstrictCSP = () => { | ||||||
|  | @ -27,11 +27,10 @@ const unstrictCSP = () => { | ||||||
|         "https://api.goosemod.com/inject.js", |         "https://api.goosemod.com/inject.js", | ||||||
|         "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js", |         "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js", | ||||||
|         "https://raw.githubusercontent.com/Cumcord/Cumcord/master/dist/build.js", |         "https://raw.githubusercontent.com/Cumcord/Cumcord/master/dist/build.js", | ||||||
|     "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js", |         "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js" | ||||||
|     ]; |     ]; | ||||||
| 
 | 
 | ||||||
|   electron.session.defaultSession.webRequest.onHeadersReceived( |     electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, url}, done) => { | ||||||
|     ({ responseHeaders, url }, done) => { |  | ||||||
|         let csp = responseHeaders!["content-security-policy"]; |         let csp = responseHeaders!["content-security-policy"]; | ||||||
| 
 | 
 | ||||||
|         if (otherMods.generic.electronProxy) { |         if (otherMods.generic.electronProxy) { | ||||||
|  | @ -53,17 +52,14 @@ const unstrictCSP = () => { | ||||||
|             responseHeaders!["access-control-allow-origin"] = ["*"]; |             responseHeaders!["access-control-allow-origin"] = ["*"]; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|       done({ responseHeaders }); |         done({responseHeaders}); | ||||||
|     } |     }); | ||||||
|   ); |  | ||||||
| }; | }; | ||||||
| storage.get("settings", function (error, data: any) { | storage.get("settings", function (error, data: any) { | ||||||
|     if (error) throw error; |     if (error) throw error; | ||||||
|     if (data.armcordCSP) { |     if (data.armcordCSP) { | ||||||
|         unstrictCSP(); |         unstrictCSP(); | ||||||
|     } else { |     } else { | ||||||
|     console.log( |         console.log("ArmCord CSP is disabled. The CSP should be managed by third-party plugin."); | ||||||
|       "ArmCord CSP is disabled. The CSP should be managed by third-party plugin." |  | ||||||
|     ); |  | ||||||
|     } |     } | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,24 +1,18 @@ | ||||||
| import * as fs from 'fs'; | import * as fs from "fs"; | ||||||
| import { app, session } from 'electron'; | import {app, session} from "electron"; | ||||||
| const userDataPath = app.getPath("userData"); | const userDataPath = app.getPath("userData"); | ||||||
| const pluginFolder = userDataPath + "/plugins/"; | const pluginFolder = userDataPath + "/plugins/"; | ||||||
| if (!fs.existsSync(pluginFolder)) { | if (!fs.existsSync(pluginFolder)) { | ||||||
|     fs.mkdirSync(pluginFolder); |     fs.mkdirSync(pluginFolder); | ||||||
|     console.log("Created missing plugin folder"); |     console.log("Created missing plugin folder"); | ||||||
|   } | } | ||||||
| app.whenReady().then(() => { | app.whenReady().then(() => { | ||||||
|     fs.readdirSync(pluginFolder).forEach((file) => { |     fs.readdirSync(pluginFolder).forEach((file) => { | ||||||
|         try { |         try { | ||||||
|       const manifest = fs.readFileSync( |             const manifest = fs.readFileSync(`${userDataPath}/plugins/${file}/manifest.json`, "utf8"); | ||||||
|         `${userDataPath}/plugins/${file}/manifest.json`, |  | ||||||
|         "utf8" |  | ||||||
|       ); |  | ||||||
|             var pluginFile = JSON.parse(manifest); |             var pluginFile = JSON.parse(manifest); | ||||||
|             session.defaultSession.loadExtension(`${userDataPath}/plugins/${file}`); |             session.defaultSession.loadExtension(`${userDataPath}/plugins/${file}`); | ||||||
|       console.log( |             console.log(`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`, "color:red"); | ||||||
|         `%cLoaded ${pluginFile.name} made by ${pluginFile.author}`, |  | ||||||
|         "color:red" |  | ||||||
|       ); |  | ||||||
|         } catch (err) { |         } catch (err) { | ||||||
|             console.error(err); |             console.error(err); | ||||||
|         } |         } | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								src/ipc.ts
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								src/ipc.ts
									
										
									
									
									
								
							|  | @ -1,9 +1,9 @@ | ||||||
| //ipc stuff
 | //ipc stuff
 | ||||||
| import { app, ipcMain, shell, desktopCapturer } from "electron"; | import {app, ipcMain, shell, desktopCapturer} from "electron"; | ||||||
| import { createTabsGuest, mainWindow } from "./window"; | import {createTabsGuest, mainWindow} from "./window"; | ||||||
| import { saveSettings, getVersion } from "./utils"; | import {saveSettings, getVersion} from "./utils"; | ||||||
| import { settings, customTitlebar, tabs } from "./main"; | import {settings, customTitlebar, tabs} from "./main"; | ||||||
| import { createSettingsWindow } from "./settings/main"; | import {createSettingsWindow} from "./settings/main"; | ||||||
| export function registerIpc() { | export function registerIpc() { | ||||||
|     ipcMain.on("get-app-path", (event, arg) => { |     ipcMain.on("get-app-path", (event, arg) => { | ||||||
|         event.reply("app-path", app.getAppPath()); |         event.reply("app-path", app.getAppPath()); | ||||||
|  | @ -77,7 +77,5 @@ export function registerIpc() { | ||||||
|             event.returnValue = false; |             event.returnValue = false; | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|   ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, opts) => |     ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, opts) => desktopCapturer.getSources(opts)); | ||||||
|     desktopCapturer.getSources(opts) |  | ||||||
|   ); |  | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								src/main.ts
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.ts
									
										
									
									
									
								
							|  | @ -1,31 +1,27 @@ | ||||||
| // Modules to control application life and create native browser window
 | // Modules to control application life and create native browser window
 | ||||||
| import { | import {app, BrowserWindow, session} from "electron"; | ||||||
|   app, |  | ||||||
|   BrowserWindow, |  | ||||||
|   session, |  | ||||||
| } from "electron"; |  | ||||||
| import * as path from "path"; | import * as path from "path"; | ||||||
| import "v8-compile-cache"; | import "v8-compile-cache"; | ||||||
| import * as storage from "electron-json-storage"; | import * as storage from "electron-json-storage"; | ||||||
| import { getConfigUnsafe, setup } from "./utils"; | import {getConfigUnsafe, setup} from "./utils"; | ||||||
| import "./extensions/mods"; | import "./extensions/mods"; | ||||||
| import "./extensions/plugin"; | import "./extensions/plugin"; | ||||||
| import "./tray"; | import "./tray"; | ||||||
| import { mainWindow, createCustomWindow, createNativeWindow, createGlasstronWindow, createTabsHost } from "./window"; | import {mainWindow, createCustomWindow, createNativeWindow, createGlasstronWindow, createTabsHost} from "./window"; | ||||||
| import "./shortcuts"; | import "./shortcuts"; | ||||||
| export var contentPath: string; | export var contentPath: string; | ||||||
| var channel: string; | var channel: string; | ||||||
| export var settings: any; | export var settings: any; | ||||||
| export var customTitlebar: boolean; | export var customTitlebar: boolean; | ||||||
| export var tabs: boolean; | export var tabs: boolean; | ||||||
| async function appendSwitch(){ | async function appendSwitch() { | ||||||
|   if (await getConfigUnsafe("windowStyle") == "glasstron") { |     if ((await getConfigUnsafe("windowStyle")) == "glasstron") { | ||||||
|         console.log("Enabling transparency visuals."); |         console.log("Enabling transparency visuals."); | ||||||
|         app.commandLine.appendSwitch("enable-transparent-visuals"); |         app.commandLine.appendSwitch("enable-transparent-visuals"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| appendSwitch(); | appendSwitch(); | ||||||
|   storage.has("settings", function (error, hasKey) { | storage.has("settings", function (error, hasKey) { | ||||||
|     if (error) throw error; |     if (error) throw error; | ||||||
| 
 | 
 | ||||||
|     if (!hasKey) { |     if (!hasKey) { | ||||||
|  | @ -42,7 +38,7 @@ appendSwitch(); | ||||||
|             contentPath = path.join(__dirname, "/ts-out/content/splash.html"); |             contentPath = path.join(__dirname, "/ts-out/content/splash.html"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   }); | }); | ||||||
| storage.get("settings", function (error, data: any) { | storage.get("settings", function (error, data: any) { | ||||||
|     if (error) throw error; |     if (error) throw error; | ||||||
|     console.log(data); |     console.log(data); | ||||||
|  | @ -78,9 +74,7 @@ app.whenReady().then(async () => { | ||||||
|             customTitlebar = true; |             customTitlebar = true; | ||||||
|             break; |             break; | ||||||
|     } |     } | ||||||
|   session |     session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => { | ||||||
|     .fromPartition("some-partition") |  | ||||||
|     .setPermissionRequestHandler((webContents, permission, callback) => { |  | ||||||
|         if (permission === "notifications") { |         if (permission === "notifications") { | ||||||
|             // Approves the permissions request
 |             // Approves the permissions request
 | ||||||
|             callback(true); |             callback(true); | ||||||
|  |  | ||||||
|  | @ -1,33 +1,30 @@ | ||||||
| import { contextBridge, ipcRenderer } from "electron"; | import {contextBridge, ipcRenderer} from "electron"; | ||||||
| import { getDisplayMediaSelector } from "./capturer"; | import {getDisplayMediaSelector} from "./capturer"; | ||||||
| import { injectTitlebar } from "./titlebar"; | import {injectTitlebar} from "./titlebar"; | ||||||
| 
 | 
 | ||||||
| contextBridge.exposeInMainWorld("armcord", { | contextBridge.exposeInMainWorld("armcord", { | ||||||
|     window: { |     window: { | ||||||
|         show: () => ipcRenderer.send("win-show"), |         show: () => ipcRenderer.send("win-show"), | ||||||
|         hide: () => ipcRenderer.send("win-hide"), |         hide: () => ipcRenderer.send("win-hide"), | ||||||
|         minimize: () => ipcRenderer.send("win-minimize"), |         minimize: () => ipcRenderer.send("win-minimize"), | ||||||
|     maximize: () => ipcRenderer.send("win-maximize"), |         maximize: () => ipcRenderer.send("win-maximize") | ||||||
|     }, |     }, | ||||||
|     titlebar: { |     titlebar: { | ||||||
|         injectTitlebar: () => injectTitlebar(), |         injectTitlebar: () => injectTitlebar(), | ||||||
|     isTitlebar: ipcRenderer.sendSync("titlebar"), |         isTitlebar: ipcRenderer.sendSync("titlebar") | ||||||
|     }, |     }, | ||||||
|     electron: process.versions.electron, |     electron: process.versions.electron, | ||||||
|     channel: ipcRenderer.sendSync("channel"), |     channel: ipcRenderer.sendSync("channel"), | ||||||
|     openTab: (number: number) => ipcRenderer.sendSync("openTab", number), |     openTab: (number: number) => ipcRenderer.sendSync("openTab", number), | ||||||
|     version: ipcRenderer.sendSync("get-app-version", "app-version"), |     version: ipcRenderer.sendSync("get-app-version", "app-version"), | ||||||
|     getDisplayMediaSelector: getDisplayMediaSelector, |     getDisplayMediaSelector: getDisplayMediaSelector, | ||||||
|   openSettingsWindow: () => ipcRenderer.send("openSettingsWindow"), |     openSettingsWindow: () => ipcRenderer.send("openSettingsWindow") | ||||||
| }); | }); | ||||||
| //to be only used inside armcord internal setup/splash etc
 | //to be only used inside armcord internal setup/splash etc
 | ||||||
| if ( | if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) { | ||||||
|   window.location.href.indexOf("splash.html") > -1 || |  | ||||||
|   window.location.href.indexOf("setup.html") > -1 |  | ||||||
| ) { |  | ||||||
|     contextBridge.exposeInMainWorld("armcordinternal", { |     contextBridge.exposeInMainWorld("armcordinternal", { | ||||||
|         restart: () => ipcRenderer.send("restart"), |         restart: () => ipcRenderer.send("restart"), | ||||||
|         saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args), |         saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args), | ||||||
|     splashEnd: () => ipcRenderer.send("splashEnd"), |         splashEnd: () => ipcRenderer.send("splashEnd") | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -1,12 +1,11 @@ | ||||||
| //Fixed context isolation version https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.ts
 | //Fixed context isolation version https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.ts
 | ||||||
| //original https://github.com/electron/electron/issues/16513#issuecomment-602070250
 | //original https://github.com/electron/electron/issues/16513#issuecomment-602070250
 | ||||||
| import { ipcRenderer } from 'electron'; | import {ipcRenderer} from "electron"; | ||||||
| import {addStyle, addScript} from '../utils'; | import {addStyle, addScript} from "../utils"; | ||||||
| const desktopCapturer = { | const desktopCapturer = { | ||||||
|   getSources: (opts: any) => |     getSources: (opts: any) => ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts) | ||||||
|     ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts), |  | ||||||
| }; | }; | ||||||
| const CANCEL_ID = 'desktop-capturer-selection__cancel'; | const CANCEL_ID = "desktop-capturer-selection__cancel"; | ||||||
| 
 | 
 | ||||||
| interface IPCSources { | interface IPCSources { | ||||||
|     id: string; |     id: string; | ||||||
|  | @ -16,22 +15,22 @@ interface IPCSources { | ||||||
| 
 | 
 | ||||||
| export async function getDisplayMediaSelector() { | export async function getDisplayMediaSelector() { | ||||||
|     const sources: IPCSources[] = await desktopCapturer.getSources({ |     const sources: IPCSources[] = await desktopCapturer.getSources({ | ||||||
|     types: ['screen', 'window'], |         types: ["screen", "window"] | ||||||
|     }); |     }); | ||||||
|     return `<div class="desktop-capturer-selection__scroller">
 |     return `<div class="desktop-capturer-selection__scroller">
 | ||||||
|   <ul class="desktop-capturer-selection__list"> |   <ul class="desktop-capturer-selection__list"> | ||||||
|     ${sources |     ${sources | ||||||
|         .map( |         .map( | ||||||
|         ({ id, name, thumbnail }) => ` |             ({id, name, thumbnail}) => ` | ||||||
|       <li class="desktop-capturer-selection__item"> |       <li class="desktop-capturer-selection__item"> | ||||||
|         <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> |         <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> | ||||||
|           <img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" /> |           <img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" /> | ||||||
|           <span class="desktop-capturer-selection__name">${name}</span> |           <span class="desktop-capturer-selection__name">${name}</span> | ||||||
|         </button> |         </button> | ||||||
|       </li> |       </li> | ||||||
|     `,
 |     ` | ||||||
|         ) |         ) | ||||||
|       .join('')} |         .join("")} | ||||||
|     <li class="desktop-capturer-selection__item"> |     <li class="desktop-capturer-selection__item"> | ||||||
|       <button class="desktop-capturer-selection__btn" data-id="${CANCEL_ID}" title="Cancel"> |       <button class="desktop-capturer-selection__btn" data-id="${CANCEL_ID}" title="Cancel"> | ||||||
|         <span class="desktop-capturer-selection__name desktop-capturer-selection__name--cancel">Cancel</span> |         <span class="desktop-capturer-selection__name desktop-capturer-selection__name--cancel">Cancel</span> | ||||||
|  | @ -154,9 +153,8 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve | ||||||
| }); | }); | ||||||
| `;
 | `;
 | ||||||
| 
 | 
 | ||||||
| document.addEventListener("DOMContentLoaded", function() { | document.addEventListener("DOMContentLoaded", function () { | ||||||
|     addScript(screenShareJS); |     addScript(screenShareJS); | ||||||
|     addStyle(screenShareCSS); |     addStyle(screenShareCSS); | ||||||
|   console.log("Capturer injected.") |     console.log("Capturer injected."); | ||||||
| }); | }); | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| // What does this do?
 | // What does this do?
 | ||||||
| // In case of faulty update of ArmCord we can quickly push an update to the user and possibly try to fix it
 | // In case of faulty update of ArmCord we can quickly push an update to the user and possibly try to fix it
 | ||||||
| // This is completely optional and is disabled by default in settings
 | // This is completely optional and is disabled by default in settings
 | ||||||
| import { ipcRenderer } from "electron"; | import {ipcRenderer} from "electron"; | ||||||
| import { injectJS } from "../utils"; | import {injectJS} from "../utils"; | ||||||
| 
 | 
 | ||||||
| var patchEndpoint = "https://patch.armcord.xyz/"; | var patchEndpoint = "https://patch.armcord.xyz/"; | ||||||
| var version = ipcRenderer.sendSync("get-app-version", "app-version"); | var version = ipcRenderer.sendSync("get-app-version", "app-version"); | ||||||
|  | @ -15,7 +15,7 @@ if (ipcRenderer.sendSync("shouldPatch")) { | ||||||
|                     console.log("Found a patch. Injecting..."); |                     console.log("Found a patch. Injecting..."); | ||||||
|                     injectJS(patchEndpoint + version + "/patch.js"); |                     injectJS(patchEndpoint + version + "/patch.js"); | ||||||
|                 } else { |                 } else { | ||||||
|             console.log("No patches have been found.") |                     console.log("No patches have been found."); | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
| import "./bridge"; | import "./bridge"; | ||||||
| import "./capturer"; | import "./capturer"; | ||||||
| import "./patch" | import "./patch"; | ||||||
| import * as fs from "fs"; | import * as fs from "fs"; | ||||||
| import * as path from "path"; | import * as path from "path"; | ||||||
| import { injectTitlebar } from "./titlebar"; | import {injectTitlebar} from "./titlebar"; | ||||||
| import { sleep, addStyle, injectJS } from "../utils"; | import {sleep, addStyle, injectJS} from "../utils"; | ||||||
| import { ipcRenderer } from "electron"; | import {ipcRenderer} from "electron"; | ||||||
| import { injectTabs } from "./tabs"; | import {injectTabs} from "./tabs"; | ||||||
| declare global { | declare global { | ||||||
|     interface Window { |     interface Window { | ||||||
|         armcord: any; |         armcord: any; | ||||||
|  | @ -14,9 +14,8 @@ declare global { | ||||||
| } | } | ||||||
| const clientMods = { | const clientMods = { | ||||||
|     goosemod: "https://api.goosemod.com/inject.js", |     goosemod: "https://api.goosemod.com/inject.js", | ||||||
|   cumcord: |     cumcord: "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js", | ||||||
|     "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js", |     flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js" | ||||||
|   flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js", |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| console.log("ArmCord"); | console.log("ArmCord"); | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import { addStyle } from "../utils"; | import {addStyle} from "../utils"; | ||||||
| import * as fs from "fs"; | import * as fs from "fs"; | ||||||
| import * as path from "path"; | import * as path from "path"; | ||||||
| export function injectTabs() { | export function injectTabs() { | ||||||
|  | @ -22,4 +22,5 @@ export function injectTabs() { | ||||||
|         } |         } | ||||||
|         const cssPath = path.join(__dirname, "../", "/content/css/tabs.css"); |         const cssPath = path.join(__dirname, "../", "/content/css/tabs.css"); | ||||||
|         addStyle(fs.readFileSync(cssPath, "utf8")); |         addStyle(fs.readFileSync(cssPath, "utf8")); | ||||||
| })} |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import { ipcRenderer } from "electron"; | import {ipcRenderer} from "electron"; | ||||||
| import { addStyle } from "../utils"; | import {addStyle} from "../utils"; | ||||||
| import * as fs from "fs"; | import * as fs from "fs"; | ||||||
| import * as path from "path"; | import * as path from "path"; | ||||||
| export function injectTitlebar() { | export function injectTitlebar() { | ||||||
|  |  | ||||||
|  | @ -1,15 +1,15 @@ | ||||||
| import { BrowserWindow, shell, ipcMain } from "electron"; | import {BrowserWindow, shell, ipcMain} from "electron"; | ||||||
| import * as storage from "electron-json-storage"; | import * as storage from "electron-json-storage"; | ||||||
| import {getConfigUnsafe, saveSettings, Settings} from "../utils"; | import {getConfigUnsafe, saveSettings, Settings} from "../utils"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| var settings:any; | var settings: any; | ||||||
| var isAlreadyCreated:boolean = false; | var isAlreadyCreated: boolean = false; | ||||||
| storage.get("settings", function (error, data: any) { | storage.get("settings", function (error, data: any) { | ||||||
|     if (error) throw error; |     if (error) throw error; | ||||||
|     console.log(data); |     console.log(data); | ||||||
|     settings = data; |     settings = data; | ||||||
| }); | }); | ||||||
| var settingsWindow:BrowserWindow; | var settingsWindow: BrowserWindow; | ||||||
| export function createSettingsWindow() { | export function createSettingsWindow() { | ||||||
|     if (isAlreadyCreated) { |     if (isAlreadyCreated) { | ||||||
|         settingsWindow.show(); |         settingsWindow.show(); | ||||||
|  | @ -22,8 +22,8 @@ export function createSettingsWindow() { | ||||||
|             frame: true, |             frame: true, | ||||||
|             autoHideMenuBar: true, |             autoHideMenuBar: true, | ||||||
|             webPreferences: { |             webPreferences: { | ||||||
|       preload: path.join(__dirname, "preload.js"), |                 preload: path.join(__dirname, "preload.js") | ||||||
|     }, |             } | ||||||
|         }); |         }); | ||||||
|         ipcMain.on("saveSettings", (event, args: Settings) => { |         ipcMain.on("saveSettings", (event, args: Settings) => { | ||||||
|             console.log(args); |             console.log(args); | ||||||
|  | @ -32,15 +32,15 @@ export function createSettingsWindow() { | ||||||
|         ipcMain.handle("getSetting", (event, toGet: string) => { |         ipcMain.handle("getSetting", (event, toGet: string) => { | ||||||
|             return getConfigUnsafe(toGet); |             return getConfigUnsafe(toGet); | ||||||
|         }); |         }); | ||||||
|   settingsWindow.webContents.setWindowOpenHandler(({ url }) => { |         settingsWindow.webContents.setWindowOpenHandler(({url}) => { | ||||||
|             shell.openExternal(url); |             shell.openExternal(url); | ||||||
|     return { action: "deny" }; |             return {action: "deny"}; | ||||||
|         }); |         }); | ||||||
|         settingsWindow.loadURL(`file://${__dirname}/settings.html`); |         settingsWindow.loadURL(`file://${__dirname}/settings.html`); | ||||||
|         settingsWindow.on("close", async (e) => { |         settingsWindow.on("close", async (e) => { | ||||||
|     e.preventDefault() |             e.preventDefault(); | ||||||
|     settingsWindow.hide() |             settingsWindow.hide(); | ||||||
|         }); |         }); | ||||||
|         isAlreadyCreated = true; |         isAlreadyCreated = true; | ||||||
| } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,9 @@ | ||||||
| import {contextBridge, ipcRenderer} from "electron"; | import {contextBridge, ipcRenderer} from "electron"; | ||||||
| console.log("ArmCord Settings") | console.log("ArmCord Settings"); | ||||||
| contextBridge.exposeInMainWorld("settings", { | contextBridge.exposeInMainWorld("settings", { | ||||||
|     save: (...args: any) => ipcRenderer.send("saveSettings", ...args), |     save: (...args: any) => ipcRenderer.send("saveSettings", ...args), | ||||||
|   get: (toGet: string) => ipcRenderer.invoke('getSetting', toGet).then((result) => {return result}) //jank but works
 |     get: (toGet: string) => | ||||||
|  |         ipcRenderer.invoke("getSetting", toGet).then((result) => { | ||||||
|  |             return result; | ||||||
|  |         }) //jank but works
 | ||||||
| }); | }); | ||||||
|  | @ -51,8 +51,8 @@ body { | ||||||
|     cursor: default; |     cursor: default; | ||||||
| } | } | ||||||
| .left { | .left { | ||||||
|     float:right; |     float: right; | ||||||
|     vertical-align: right!important; |     vertical-align: right !important; | ||||||
| } | } | ||||||
| .switch { | .switch { | ||||||
|     vertical-align: middle; |     vertical-align: middle; | ||||||
|  | @ -87,13 +87,31 @@ button:hover { | ||||||
| .tgl { | .tgl { | ||||||
|     display: none; |     display: none; | ||||||
| } | } | ||||||
| .tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl + .tgl-btn { | .tgl, | ||||||
|  | .tgl:after, | ||||||
|  | .tgl:before, | ||||||
|  | .tgl *, | ||||||
|  | .tgl *:after, | ||||||
|  | .tgl *:before, | ||||||
|  | .tgl + .tgl-btn { | ||||||
|     box-sizing: border-box; |     box-sizing: border-box; | ||||||
| } | } | ||||||
| .tgl::-moz-selection, .tgl:after::-moz-selection, .tgl:before::-moz-selection, .tgl *::-moz-selection, .tgl *:after::-moz-selection, .tgl *:before::-moz-selection, .tgl + .tgl-btn::-moz-selection { | .tgl::-moz-selection, | ||||||
|  | .tgl:after::-moz-selection, | ||||||
|  | .tgl:before::-moz-selection, | ||||||
|  | .tgl *::-moz-selection, | ||||||
|  | .tgl *:after::-moz-selection, | ||||||
|  | .tgl *:before::-moz-selection, | ||||||
|  | .tgl + .tgl-btn::-moz-selection { | ||||||
|     background: none; |     background: none; | ||||||
| } | } | ||||||
| .tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl + .tgl-btn::selection { | .tgl::selection, | ||||||
|  | .tgl:after::selection, | ||||||
|  | .tgl:before::selection, | ||||||
|  | .tgl *::selection, | ||||||
|  | .tgl *:after::selection, | ||||||
|  | .tgl *:before::selection, | ||||||
|  | .tgl + .tgl-btn::selection { | ||||||
|     background: none; |     background: none; | ||||||
| } | } | ||||||
| .tgl + .tgl-btn { | .tgl + .tgl-btn { | ||||||
|  | @ -108,7 +126,8 @@ button:hover { | ||||||
|     -ms-user-select: none; |     -ms-user-select: none; | ||||||
|     user-select: none; |     user-select: none; | ||||||
| } | } | ||||||
| .tgl + .tgl-btn:after, .tgl + .tgl-btn:before { | .tgl + .tgl-btn:after, | ||||||
|  | .tgl + .tgl-btn:before { | ||||||
|     position: relative; |     position: relative; | ||||||
|     display: block; |     display: block; | ||||||
|     content: ""; |     content: ""; | ||||||
|  |  | ||||||
|  | @ -1,17 +1,15 @@ | ||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
| <html lang="en"> | <html lang="en"> | ||||||
| 
 |     <head> | ||||||
| <head> |  | ||||||
|         <meta charset="UTF-8" /> |         <meta charset="UTF-8" /> | ||||||
|         <title>ArmCord Settings</title> |         <title>ArmCord Settings</title> | ||||||
|         <style> |         <style> | ||||||
|             @import url("settings.css"); |             @import url("settings.css"); | ||||||
|         </style> |         </style> | ||||||
| </head> |     </head> | ||||||
| 
 | 
 | ||||||
| <body> |     <body> | ||||||
| 
 |         <div class="switch"> | ||||||
| <div class="switch"> |  | ||||||
|             <select name="theme" id="theme" class="left"> |             <select name="theme" id="theme" class="left"> | ||||||
|                 <option value="default">Default</option> |                 <option value="default">Default</option> | ||||||
|                 <option value="native">Native</option> |                 <option value="native">Native</option> | ||||||
|  | @ -20,19 +18,19 @@ | ||||||
|             </select> |             </select> | ||||||
|             <p class="header">ArmCord theme:</p> |             <p class="header">ArmCord theme:</p> | ||||||
|         </div> |         </div> | ||||||
|   </br> |         <br /> | ||||||
|         <div class="switch"> |         <div class="switch"> | ||||||
|             <label class="header">ArmCord CSP</label> |             <label class="header">ArmCord CSP</label> | ||||||
|             <input class="tgl tgl-light left" id="csp" type="checkbox" /> |             <input class="tgl tgl-light left" id="csp" type="checkbox" /> | ||||||
|             <label class="tgl-btn left" for="csp"></label> |             <label class="tgl-btn left" for="csp"></label> | ||||||
|         </div> |         </div> | ||||||
|   </br> |         <br /> | ||||||
|         <div class="switch"> |         <div class="switch"> | ||||||
|             <label class="header">Minimize to tray</label> |             <label class="header">Minimize to tray</label> | ||||||
|             <input class="tgl tgl-light left" id="tray" type="checkbox" /> |             <input class="tgl tgl-light left" id="tray" type="checkbox" /> | ||||||
|             <label class="tgl-btn left" for="tray"></label> |             <label class="tgl-btn left" for="tray"></label> | ||||||
|         </div> |         </div> | ||||||
|   </br> |         <br /> | ||||||
|         <div class="switch"> |         <div class="switch"> | ||||||
|             <label class="header">Automatic Patches</label> |             <label class="header">Automatic Patches</label> | ||||||
|             <input class="tgl tgl-light left" id="patches" type="checkbox" /> |             <input class="tgl tgl-light left" id="patches" type="checkbox" /> | ||||||
|  | @ -65,10 +63,9 @@ | ||||||
|             <p class="header">Glasstron blur type:</p> |             <p class="header">Glasstron blur type:</p> | ||||||
|         </div> |         </div> | ||||||
|         <button id="save" class="center">Save settings</button> |         <button id="save" class="center">Save settings</button> | ||||||
|  |     </body> | ||||||
| 
 | 
 | ||||||
| </body> |     <script> | ||||||
| 
 |  | ||||||
| <script> |  | ||||||
|         async function loadSettings() { |         async function loadSettings() { | ||||||
|             document.getElementById("csp").checked = await settings.get("armcordCSP"); |             document.getElementById("csp").checked = await settings.get("armcordCSP"); | ||||||
|             document.getElementById("tray").checked = await settings.get("minimizeToTray"); |             document.getElementById("tray").checked = await settings.get("minimizeToTray"); | ||||||
|  | @ -78,11 +75,18 @@ | ||||||
|             document.getElementById("theme").value = await settings.get("windowStyle"); |             document.getElementById("theme").value = await settings.get("windowStyle"); | ||||||
|             document.getElementById("blurType").value = await settings.get("blurType"); |             document.getElementById("blurType").value = await settings.get("blurType"); | ||||||
|         } |         } | ||||||
|   loadSettings() |         loadSettings(); | ||||||
|   document.getElementById("save").addEventListener("click", function() { |         document.getElementById("save").addEventListener("click", function () { | ||||||
|             //function saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray: boolean, automaticPatches: boolean,modsSetting: string, blurType: string) |             //function saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray: boolean, automaticPatches: boolean,modsSetting: string, blurType: string) | ||||||
|     settings.save(document.getElementById("theme").value, document.getElementById("channel").value, document.getElementById("csp").checked, document.getElementById("tray").checked, document.getElementById("patches").checked, document.getElementById("mod").value, document.getElementById("blurType").value); |             settings.save( | ||||||
|  |                 document.getElementById("theme").value, | ||||||
|  |                 document.getElementById("channel").value, | ||||||
|  |                 document.getElementById("csp").checked, | ||||||
|  |                 document.getElementById("tray").checked, | ||||||
|  |                 document.getElementById("patches").checked, | ||||||
|  |                 document.getElementById("mod").value, | ||||||
|  |                 document.getElementById("blurType").value | ||||||
|  |             ); | ||||||
|         }); |         }); | ||||||
| </script> |     </script> | ||||||
| 
 |  | ||||||
| </html> | </html> | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| import { app } from "electron"; | import {app} from "electron"; | ||||||
| import {mainWindow} from './window'; | import {mainWindow} from "./window"; | ||||||
| //https://github.com/electron/electron/issues/1334#issuecomment-716080005
 | //https://github.com/electron/electron/issues/1334#issuecomment-716080005
 | ||||||
| // TO-DO add more
 | // TO-DO add more
 | ||||||
| app.on("web-contents-created", (webContentsCreatedEvent, webContents) => { | app.on("web-contents-created", (webContentsCreatedEvent, webContents) => { | ||||||
|     webContents.on("before-input-event", (beforeInputEvent, input) => { |     webContents.on("before-input-event", (beforeInputEvent, input) => { | ||||||
|         // console.log('Main console::', input)
 |         // console.log('Main console::', input)
 | ||||||
|     const { code, alt, control, shift, meta } = input; |         const {code, alt, control, shift, meta} = input; | ||||||
|         // Shortcut: toggle devTools
 |         // Shortcut: toggle devTools
 | ||||||
|         if (shift && control && !alt && !meta && code === "KeyI") { |         if (shift && control && !alt && !meta && code === "KeyI") { | ||||||
|             mainWindow.webContents.toggleDevTools(); |             mainWindow.webContents.toggleDevTools(); | ||||||
|  |  | ||||||
							
								
								
									
										28
									
								
								src/tray.ts
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								src/tray.ts
									
										
									
									
									
								
							|  | @ -1,38 +1,38 @@ | ||||||
| import { app, Menu, Tray } from 'electron'; | import {app, Menu, Tray} from "electron"; | ||||||
| import {mainWindow} from './window'; | import {mainWindow} from "./window"; | ||||||
| import * as path from 'path' | import * as path from "path"; | ||||||
| import { createSettingsWindow } from './settings/main'; | import {createSettingsWindow} from "./settings/main"; | ||||||
| let tray = null | let tray = null; | ||||||
| app.whenReady().then(() => { | app.whenReady().then(() => { | ||||||
|   tray = new Tray(path.join(__dirname, "../", "/assets/ac_plug.png")) |     tray = new Tray(path.join(__dirname, "../", "/assets/ac_plug.png")); | ||||||
|     const contextMenu = Menu.buildFromTemplate([ |     const contextMenu = Menu.buildFromTemplate([ | ||||||
|         { |         { | ||||||
|             label: "Open ArmCord", |             label: "Open ArmCord", | ||||||
|             click: function () { |             click: function () { | ||||||
|                 mainWindow.show(); |                 mainWindow.show(); | ||||||
|       }, |             } | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             label: "Open Settings", |             label: "Open Settings", | ||||||
|             click: function () { |             click: function () { | ||||||
|                 createSettingsWindow(); |                 createSettingsWindow(); | ||||||
|       }, |             } | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             label: "Support Discord Server", |             label: "Support Discord Server", | ||||||
|             click: function () { |             click: function () { | ||||||
|                 mainWindow.show(); |                 mainWindow.show(); | ||||||
|                 mainWindow.loadURL("https://discord.gg/pZtWQBFjk6"); |                 mainWindow.loadURL("https://discord.gg/pZtWQBFjk6"); | ||||||
|       }, |             } | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             label: "Quit ArmCord", |             label: "Quit ArmCord", | ||||||
|             click: function () { |             click: function () { | ||||||
|                 app.quit(); |                 app.quit(); | ||||||
|       }, |             } | ||||||
|     }, |         } | ||||||
|     ]); |     ]); | ||||||
| 
 | 
 | ||||||
|   tray.setToolTip('ArmCord ' + app.getVersion()) |     tray.setToolTip("ArmCord " + app.getVersion()); | ||||||
|   tray.setContextMenu(contextMenu) |     tray.setContextMenu(contextMenu); | ||||||
| }) | }); | ||||||
|  |  | ||||||
							
								
								
									
										24
									
								
								src/types/glasstron.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								src/types/glasstron.d.ts
									
										
									
									
										vendored
									
									
								
							|  | @ -30,11 +30,7 @@ declare module "glasstron" { | ||||||
|         static injectOnElectron(): void; |         static injectOnElectron(): void; | ||||||
|         static delayReadyEvent(): void; |         static delayReadyEvent(): void; | ||||||
|     } |     } | ||||||
|   export type WindowsBlurType = |     export type WindowsBlurType = "acrylic" | "blurbehind" | "transparent" | "none"; | ||||||
|     | "acrylic" |  | ||||||
|     | "blurbehind" |  | ||||||
|     | "transparent" |  | ||||||
|     | "none"; |  | ||||||
|     export type MacOSVibrancy = |     export type MacOSVibrancy = | ||||||
|         | ( |         | ( | ||||||
|               | "appearance-based" |               | "appearance-based" | ||||||
|  | @ -63,24 +59,12 @@ declare module "glasstron" { | ||||||
| declare module "glasstron/src/utils" { | declare module "glasstron/src/utils" { | ||||||
|     class Utils { |     class Utils { | ||||||
|         static getSavePath(): string; |         static getSavePath(): string; | ||||||
|     static copyToPath( |         static copyToPath(innerFile: string, outerFilename?: string, flags?: number): void; | ||||||
|       innerFile: string, |  | ||||||
|       outerFilename?: string, |  | ||||||
|       flags?: number |  | ||||||
|     ): void; |  | ||||||
|         static removeFromPath(filename: string): void; |         static removeFromPath(filename: string): void; | ||||||
|         static isInPath(filename: string): boolean; |         static isInPath(filename: string): boolean; | ||||||
|         static getPlatform(): any; |         static getPlatform(): any; | ||||||
|     static parseKeyValString( |         static parseKeyValString(string: string, keyvalSeparator?: string, pairSeparator?: string): any; | ||||||
|       string: string, |         static makeKeyValString(object: any, keyvalSeparator?: string, pairSeparator?: string): string; | ||||||
|       keyvalSeparator?: string, |  | ||||||
|       pairSeparator?: string |  | ||||||
|     ): any; |  | ||||||
|     static makeKeyValString( |  | ||||||
|       object: any, |  | ||||||
|       keyvalSeparator?: string, |  | ||||||
|       pairSeparator?: string |  | ||||||
|     ): string; |  | ||||||
|     } |     } | ||||||
|     export = Utils; |     export = Utils; | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										28
									
								
								src/utils.ts
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								src/utils.ts
									
										
									
									
									
								
							|  | @ -1,6 +1,6 @@ | ||||||
| import * as storage from "electron-json-storage"; | import * as storage from "electron-json-storage"; | ||||||
| import * as fs from "fs"; | import * as fs from "fs"; | ||||||
| import { app } from "electron"; | import {app} from "electron"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| export var firstRun: boolean; | export var firstRun: boolean; | ||||||
| 
 | 
 | ||||||
|  | @ -22,19 +22,19 @@ export async function sleep(ms: number) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function checkIfConfigIsNew() { | export async function checkIfConfigIsNew() { | ||||||
|   if (await getConfigUnsafe("automaticPatches") == undefined) { |     if ((await getConfigUnsafe("automaticPatches")) == undefined) { | ||||||
|         firstRun = true; |         firstRun = true; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface Settings { | export interface Settings { | ||||||
|   windowStyle: string, |     windowStyle: string; | ||||||
|   channel: string, |     channel: string; | ||||||
|   armcordCSP: boolean, |     armcordCSP: boolean; | ||||||
|   minimizeToTray: boolean, |     minimizeToTray: boolean; | ||||||
|   automaticPatches: boolean, |     automaticPatches: boolean; | ||||||
|   mods: string, |     mods: string; | ||||||
|   blurType: string |     blurType: string; | ||||||
| } | } | ||||||
| export function setup() { | export function setup() { | ||||||
|     console.log("Setting up temporary ArmCord settings."); |     console.log("Setting up temporary ArmCord settings."); | ||||||
|  | @ -45,13 +45,13 @@ export function setup() { | ||||||
|         minimizeToTray: true, |         minimizeToTray: true, | ||||||
|         automaticPatches: false, |         automaticPatches: false, | ||||||
|         mods: "cumcord", |         mods: "cumcord", | ||||||
|     blurType: "acrylic", |         blurType: "acrylic" | ||||||
|   } |     }; | ||||||
|     storage.set( |     storage.set( | ||||||
|         "settings", |         "settings", | ||||||
|         { |         { | ||||||
|             ...defaults, |             ...defaults, | ||||||
|       doneSetup: true, |             doneSetup: true | ||||||
|         }, |         }, | ||||||
|         function (error) { |         function (error) { | ||||||
|             if (error) throw error; |             if (error) throw error; | ||||||
|  | @ -59,9 +59,7 @@ export function setup() { | ||||||
|     ); |     ); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function saveSettings( | export function saveSettings(settings: Settings) { | ||||||
|   settings: Settings |  | ||||||
| ) { |  | ||||||
|     console.log("Setting up ArmCord settings."); |     console.log("Setting up ArmCord settings."); | ||||||
|     storage.set( |     storage.set( | ||||||
|         "settings", |         "settings", | ||||||
|  |  | ||||||
|  | @ -2,21 +2,20 @@ | ||||||
| // I had to add most of the window creation code here to split both into seperete functions
 | // I had to add most of the window creation code here to split both into seperete functions
 | ||||||
| // WHY? Because I can't use the same code for both due to annoying bug with value `frame` not responding to variables
 | // WHY? Because I can't use the same code for both due to annoying bug with value `frame` not responding to variables
 | ||||||
| // I'm sorry for this mess but I'm not sure how to fix it.
 | // I'm sorry for this mess but I'm not sure how to fix it.
 | ||||||
| import { BrowserWindow, shell, app, ipcMain } from "electron"; | import {BrowserWindow, shell, app, ipcMain} from "electron"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| import { contentPath } from "./main"; | import {contentPath} from "./main"; | ||||||
| import { checkIfConfigIsNew, firstRun, getConfigUnsafe } from "./utils"; | import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils"; | ||||||
| import { registerIpc } from "./ipc"; | import {registerIpc} from "./ipc"; | ||||||
| import contextMenu from "electron-context-menu"; | import contextMenu from "electron-context-menu"; | ||||||
| export let mainWindow: BrowserWindow; | export let mainWindow: BrowserWindow; | ||||||
| import * as glasstron from "glasstron"; | import * as glasstron from "glasstron"; | ||||||
| 
 | 
 | ||||||
| let guestWindows: BrowserWindow [] = []; | let guestWindows: BrowserWindow[] = []; | ||||||
| contextMenu({ | contextMenu({ | ||||||
|     showSaveImageAs: true, |     showSaveImageAs: true, | ||||||
|     showCopyImageAddress: true, |     showCopyImageAddress: true, | ||||||
|   showSearchWithGoogle: true, |     showSearchWithGoogle: true | ||||||
| 
 |  | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| function doAfterDefiningTheWindow() { | function doAfterDefiningTheWindow() { | ||||||
|  | @ -24,25 +23,22 @@ function doAfterDefiningTheWindow() { | ||||||
|     registerIpc(); |     registerIpc(); | ||||||
|     mainWindow.webContents.userAgent = |     mainWindow.webContents.userAgent = | ||||||
|         "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"; //fake useragent for screenshare to work
 |         "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"; //fake useragent for screenshare to work
 | ||||||
|   mainWindow.webContents.setWindowOpenHandler(({ url }) => { |     mainWindow.webContents.setWindowOpenHandler(({url}) => { | ||||||
|         shell.openExternal(url); |         shell.openExternal(url); | ||||||
|     return { action: "deny" }; |         return {action: "deny"}; | ||||||
|     }); |     }); | ||||||
|   mainWindow.webContents.session.webRequest.onBeforeRequest( |     mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => { | ||||||
|     (details, callback) => { |         if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true}); | ||||||
|       if (/api\/v\d\/science$/g.test(details.url)) |  | ||||||
|         return callback({ cancel: true }); |  | ||||||
|         return callback({}); |         return callback({}); | ||||||
|     } |     }); | ||||||
|   ); |  | ||||||
|     mainWindow.on("close", async (e) => { |     mainWindow.on("close", async (e) => { | ||||||
|         if (await getConfigUnsafe("minimizeToTray")) { |         if (await getConfigUnsafe("minimizeToTray")) { | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
|             mainWindow.hide(); |             mainWindow.hide(); | ||||||
|     } else if (!await getConfigUnsafe("minimizeToTray")) { |         } else if (!(await getConfigUnsafe("minimizeToTray"))) { | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
|             app.exit(); |             app.exit(); | ||||||
|       app.quit() |             app.quit(); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|     console.log(contentPath); |     console.log(contentPath); | ||||||
|  | @ -79,8 +75,8 @@ export function createCustomWindow() { | ||||||
|         autoHideMenuBar: true, |         autoHideMenuBar: true, | ||||||
|         webPreferences: { |         webPreferences: { | ||||||
|             preload: path.join(__dirname, "preload/preload.js"), |             preload: path.join(__dirname, "preload/preload.js"), | ||||||
|       spellcheck: true, |             spellcheck: true | ||||||
|     }, |         } | ||||||
|     }); |     }); | ||||||
|     doAfterDefiningTheWindow(); |     doAfterDefiningTheWindow(); | ||||||
| } | } | ||||||
|  | @ -95,8 +91,8 @@ export function createNativeWindow() { | ||||||
|         autoHideMenuBar: true, |         autoHideMenuBar: true, | ||||||
|         webPreferences: { |         webPreferences: { | ||||||
|             preload: path.join(__dirname, "preload/preload.js"), |             preload: path.join(__dirname, "preload/preload.js"), | ||||||
|       spellcheck: true, |             spellcheck: true | ||||||
|     }, |         } | ||||||
|     }); |     }); | ||||||
|     doAfterDefiningTheWindow(); |     doAfterDefiningTheWindow(); | ||||||
| } | } | ||||||
|  | @ -111,8 +107,8 @@ export function createGlasstronWindow() { | ||||||
|         autoHideMenuBar: true, |         autoHideMenuBar: true, | ||||||
|         webPreferences: { |         webPreferences: { | ||||||
|             preload: path.join(__dirname, "preload/preload.js"), |             preload: path.join(__dirname, "preload/preload.js"), | ||||||
|       spellcheck: true, |             spellcheck: true | ||||||
|     }, |         } | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     //@ts-expect-error
 |     //@ts-expect-error
 | ||||||
|  | @ -132,17 +128,17 @@ export function createTabsHost() { | ||||||
|         frame: true, |         frame: true, | ||||||
|         autoHideMenuBar: true, |         autoHideMenuBar: true, | ||||||
|         webPreferences: { |         webPreferences: { | ||||||
|       preload: path.join(__dirname, "preload/preload.js"), |             preload: path.join(__dirname, "preload/preload.js") | ||||||
|     }, |         } | ||||||
|     }); |     }); | ||||||
|     doAfterDefiningTheWindow(); |     doAfterDefiningTheWindow(); | ||||||
| } | } | ||||||
| export function createTabsGuest(number: number) { | export function createTabsGuest(number: number) { | ||||||
|   console.log(guestWindows) |     console.log(guestWindows); | ||||||
|     if (guestWindows[number] !== undefined || null) { |     if (guestWindows[number] !== undefined || null) { | ||||||
|         try { |         try { | ||||||
|             console.log("Showing Guest Window " + number); |             console.log("Showing Guest Window " + number); | ||||||
|       mainWindow.hide() |             mainWindow.hide(); | ||||||
|             guestWindows[number].show(); |             guestWindows[number].show(); | ||||||
|             mainWindow = guestWindows[number]; |             mainWindow = guestWindows[number]; | ||||||
|         } catch (e) { |         } catch (e) { | ||||||
|  | @ -161,8 +157,8 @@ export function createTabsGuest(number: number) { | ||||||
|             frame: true, |             frame: true, | ||||||
|             autoHideMenuBar: true, |             autoHideMenuBar: true, | ||||||
|             webPreferences: { |             webPreferences: { | ||||||
|       preload: path.join(__dirname, "preload/preload.js"), |                 preload: path.join(__dirname, "preload/preload.js") | ||||||
|     }, |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         mainWindow = guestWindows[number]; |         mainWindow = guestWindows[number]; | ||||||
|  | @ -173,18 +169,14 @@ export function createTabsGuest(number: number) { | ||||||
|         guestWindows[number].webContents.userAgent = |         guestWindows[number].webContents.userAgent = | ||||||
|             "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"; //fake useragent for screenshare to work
 |             "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"; //fake useragent for screenshare to work
 | ||||||
| 
 | 
 | ||||||
|   guestWindows[number].webContents.setWindowOpenHandler(({ url }) => { |         guestWindows[number].webContents.setWindowOpenHandler(({url}) => { | ||||||
|             shell.openExternal(url); |             shell.openExternal(url); | ||||||
|     return { action: "deny" }; |             return {action: "deny"}; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         guestWindows[number].webContents.session.webRequest.onBeforeRequest( |         guestWindows[number].webContents.session.webRequest.onBeforeRequest( | ||||||
|     ( |             (details: {url: string}, callback: (arg0: {cancel?: boolean}) => any) => { | ||||||
|       details: { url: string }, |                 if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true}); | ||||||
|       callback: (arg0: { cancel?: boolean }) => any |  | ||||||
|     ) => { |  | ||||||
|       if (/api\/v\d\/science$/g.test(details.url)) |  | ||||||
|         return callback({ cancel: true }); |  | ||||||
|                 return callback({}); |                 return callback({}); | ||||||
|             } |             } | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue