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",
|
||||
"version": "3.0.4",
|
||||
"version": "3.1.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ArmCord",
|
||||
"version": "3.0.4",
|
||||
"version": "3.1.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "OSL-3.0",
|
||||
"dependencies": {
|
||||
"electron-context-menu": "^3.1.2",
|
||||
|
@ -21,6 +22,8 @@
|
|||
"copyfiles": "^2.4.1",
|
||||
"electron": "^17.1.0",
|
||||
"electron-builder": "^22.14.13",
|
||||
"husky": "^7.0.4",
|
||||
"prettier": "^2.5.1",
|
||||
"typescript": "^4.5.4"
|
||||
}
|
||||
},
|
||||
|
@ -2020,6 +2023,21 @@
|
|||
"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": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz",
|
||||
|
@ -2724,6 +2742,18 @@
|
|||
"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": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
|
@ -5191,6 +5221,12 @@
|
|||
"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": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz",
|
||||
|
@ -5728,6 +5764,12 @@
|
|||
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=",
|
||||
"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": {
|
||||
"version": "2.0.1",
|
||||
"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/",
|
||||
"watch": "tsc -w",
|
||||
"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": {
|
||||
"type": "git",
|
||||
|
@ -25,6 +27,8 @@
|
|||
"copyfiles": "^2.4.1",
|
||||
"electron": "^17.1.0",
|
||||
"electron-builder": "^22.14.13",
|
||||
"husky": "^7.0.4",
|
||||
"prettier": "^2.5.1",
|
||||
"typescript": "^4.5.4"
|
||||
},
|
||||
"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 {
|
||||
content: "ArmCord Version: 3.1.0"!important;
|
||||
content: "ArmCord Version: 3.1.0" !important;
|
||||
height: auto;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css"
|
||||
/>
|
||||
<link rel="stylesheet" href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css" />
|
||||
<meta charset="UTF-8" />
|
||||
<title>ArmCord Setup</title>
|
||||
<style>
|
||||
|
@ -23,7 +20,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
function fade(element) {
|
||||
var op = 1; // initial opacity
|
||||
var timer = setInterval(function () {
|
||||
|
@ -51,12 +47,12 @@
|
|||
automaticPatches: false,
|
||||
mods: "cumcord",
|
||||
blurType: "acrylic"
|
||||
})
|
||||
});
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart()
|
||||
window.armcordinternal.restart();
|
||||
}, 5000);
|
||||
})
|
||||
});
|
||||
document.getElementById("full").addEventListener("click", function () {
|
||||
document.getElementById("setup").innerHTML = `
|
||||
<p class="text-center setup-ask">Choose your Discord channel/instance:</p>
|
||||
|
@ -77,9 +73,7 @@
|
|||
</div>
|
||||
<button id="next" class="center">Next</button>
|
||||
`;
|
||||
document
|
||||
.getElementById("next")
|
||||
.addEventListener("click", function () {
|
||||
document.getElementById("next").addEventListener("click", function () {
|
||||
var branch = document.getElementById("channel").value;
|
||||
var csp = document.getElementById("csp").value;
|
||||
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>
|
||||
<button id="next" class="center">Next</button>
|
||||
`;
|
||||
document
|
||||
.getElementById("next")
|
||||
.addEventListener("click", function () {
|
||||
document.getElementById("next").addEventListener("click", function () {
|
||||
var mod = document.getElementById("mod").value;
|
||||
window.armcordinternal.saveSettings({
|
||||
windowStyle: "default",
|
||||
|
@ -107,7 +99,7 @@
|
|||
automaticPatches: false,
|
||||
mods: mod,
|
||||
blurType: "acrylic"
|
||||
})
|
||||
});
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart();
|
||||
|
@ -122,10 +114,10 @@
|
|||
automaticPatches: false,
|
||||
mods: "none",
|
||||
blurType: "acrylic"
|
||||
})
|
||||
});
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart()
|
||||
window.armcordinternal.restart();
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
<body>
|
||||
<div class="container">
|
||||
<video autoplay loop class="logo" id="splashscreen-armcord">
|
||||
<source
|
||||
src="https://armcord.smartfridge.space/discord_loading.webm"
|
||||
type="video/webm"
|
||||
/>
|
||||
<source src="https://armcord.smartfridge.space/discord_loading.webm" type="video/webm" />
|
||||
</video>
|
||||
<p id="text-splashscreen"></p>
|
||||
</div>
|
||||
|
@ -22,8 +19,7 @@
|
|||
<script>
|
||||
const text = document.getElementById("text-splashscreen");
|
||||
if (window.navigator.onLine === false) {
|
||||
text.innerHTML =
|
||||
"You appear to be offline. Please connect to the internet and try again.";
|
||||
text.innerHTML = "You appear to be offline. Please connect to the internet and try again.";
|
||||
} else {
|
||||
text.innerHTML = "Starting ArmCord...";
|
||||
fetch("https://armcord.smartfridge.space/latest.json")
|
||||
|
@ -35,10 +31,9 @@
|
|||
elem.src = "https://armcord.smartfridge.space/update.webp";
|
||||
document.body.prepend(elem);
|
||||
document.getElementById("splashscreen-armcord").remove();
|
||||
text.innerHTML =
|
||||
"A new version of ArmCord is available. Please update to the latest version.";
|
||||
text.innerHTML = "A new version of ArmCord is available. Please update to the latest version.";
|
||||
} else {
|
||||
console.log("ArmCord is up to date.")
|
||||
console.log("ArmCord is up to date.");
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -12,8 +12,8 @@ import electron from "electron";
|
|||
import * as storage from "electron-json-storage";
|
||||
const otherMods = {
|
||||
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 = () => {
|
||||
|
@ -27,11 +27,10 @@ const unstrictCSP = () => {
|
|||
"https://api.goosemod.com/inject.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/FlickerMod/dist/main/build.js",
|
||||
"https://raw.githubusercontent.com/FlickerMod/dist/main/build.js"
|
||||
];
|
||||
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(
|
||||
({ responseHeaders, url }, done) => {
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, url}, done) => {
|
||||
let csp = responseHeaders!["content-security-policy"];
|
||||
|
||||
if (otherMods.generic.electronProxy) {
|
||||
|
@ -53,17 +52,14 @@ const unstrictCSP = () => {
|
|||
responseHeaders!["access-control-allow-origin"] = ["*"];
|
||||
}
|
||||
|
||||
done({ responseHeaders });
|
||||
}
|
||||
);
|
||||
done({responseHeaders});
|
||||
});
|
||||
};
|
||||
storage.get("settings", function (error, data: any) {
|
||||
if (error) throw error;
|
||||
if (data.armcordCSP) {
|
||||
unstrictCSP();
|
||||
} else {
|
||||
console.log(
|
||||
"ArmCord CSP is disabled. The CSP should be managed by third-party plugin."
|
||||
);
|
||||
console.log("ArmCord CSP is disabled. The CSP should be managed by third-party plugin.");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
import * as fs from 'fs';
|
||||
import { app, session } from 'electron';
|
||||
import * as fs from "fs";
|
||||
import {app, session} from "electron";
|
||||
const userDataPath = app.getPath("userData");
|
||||
const pluginFolder = userDataPath + "/plugins/";
|
||||
if (!fs.existsSync(pluginFolder)) {
|
||||
fs.mkdirSync(pluginFolder);
|
||||
console.log("Created missing plugin folder");
|
||||
}
|
||||
}
|
||||
app.whenReady().then(() => {
|
||||
fs.readdirSync(pluginFolder).forEach((file) => {
|
||||
try {
|
||||
const manifest = fs.readFileSync(
|
||||
`${userDataPath}/plugins/${file}/manifest.json`,
|
||||
"utf8"
|
||||
);
|
||||
const manifest = fs.readFileSync(`${userDataPath}/plugins/${file}/manifest.json`, "utf8");
|
||||
var pluginFile = JSON.parse(manifest);
|
||||
session.defaultSession.loadExtension(`${userDataPath}/plugins/${file}`);
|
||||
console.log(
|
||||
`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`,
|
||||
"color:red"
|
||||
);
|
||||
console.log(`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`, "color:red");
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
14
src/ipc.ts
14
src/ipc.ts
|
@ -1,9 +1,9 @@
|
|||
//ipc stuff
|
||||
import { app, ipcMain, shell, desktopCapturer } from "electron";
|
||||
import { createTabsGuest, mainWindow } from "./window";
|
||||
import { saveSettings, getVersion } from "./utils";
|
||||
import { settings, customTitlebar, tabs } from "./main";
|
||||
import { createSettingsWindow } from "./settings/main";
|
||||
import {app, ipcMain, shell, desktopCapturer} from "electron";
|
||||
import {createTabsGuest, mainWindow} from "./window";
|
||||
import {saveSettings, getVersion} from "./utils";
|
||||
import {settings, customTitlebar, tabs} from "./main";
|
||||
import {createSettingsWindow} from "./settings/main";
|
||||
export function registerIpc() {
|
||||
ipcMain.on("get-app-path", (event, arg) => {
|
||||
event.reply("app-path", app.getAppPath());
|
||||
|
@ -77,7 +77,5 @@ export function registerIpc() {
|
|||
event.returnValue = false;
|
||||
}
|
||||
});
|
||||
ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, opts) =>
|
||||
desktopCapturer.getSources(opts)
|
||||
);
|
||||
ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, 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
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
session,
|
||||
} from "electron";
|
||||
import {app, BrowserWindow, session} from "electron";
|
||||
import * as path from "path";
|
||||
import "v8-compile-cache";
|
||||
import * as storage from "electron-json-storage";
|
||||
import { getConfigUnsafe, setup } from "./utils";
|
||||
import {getConfigUnsafe, setup} from "./utils";
|
||||
import "./extensions/mods";
|
||||
import "./extensions/plugin";
|
||||
import "./tray";
|
||||
import { mainWindow, createCustomWindow, createNativeWindow, createGlasstronWindow, createTabsHost } from "./window";
|
||||
import {mainWindow, createCustomWindow, createNativeWindow, createGlasstronWindow, createTabsHost} from "./window";
|
||||
import "./shortcuts";
|
||||
export var contentPath: string;
|
||||
var channel: string;
|
||||
export var settings: any;
|
||||
export var customTitlebar: boolean;
|
||||
export var tabs: boolean;
|
||||
async function appendSwitch(){
|
||||
if (await getConfigUnsafe("windowStyle") == "glasstron") {
|
||||
async function appendSwitch() {
|
||||
if ((await getConfigUnsafe("windowStyle")) == "glasstron") {
|
||||
console.log("Enabling transparency visuals.");
|
||||
app.commandLine.appendSwitch("enable-transparent-visuals");
|
||||
}
|
||||
}
|
||||
appendSwitch();
|
||||
storage.has("settings", function (error, hasKey) {
|
||||
storage.has("settings", function (error, hasKey) {
|
||||
if (error) throw error;
|
||||
|
||||
if (!hasKey) {
|
||||
|
@ -42,7 +38,7 @@ appendSwitch();
|
|||
contentPath = path.join(__dirname, "/ts-out/content/splash.html");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
storage.get("settings", function (error, data: any) {
|
||||
if (error) throw error;
|
||||
console.log(data);
|
||||
|
@ -78,9 +74,7 @@ app.whenReady().then(async () => {
|
|||
customTitlebar = true;
|
||||
break;
|
||||
}
|
||||
session
|
||||
.fromPartition("some-partition")
|
||||
.setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
if (permission === "notifications") {
|
||||
// Approves the permissions request
|
||||
callback(true);
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
import { contextBridge, ipcRenderer } from "electron";
|
||||
import { getDisplayMediaSelector } from "./capturer";
|
||||
import { injectTitlebar } from "./titlebar";
|
||||
import {contextBridge, ipcRenderer} from "electron";
|
||||
import {getDisplayMediaSelector} from "./capturer";
|
||||
import {injectTitlebar} from "./titlebar";
|
||||
|
||||
contextBridge.exposeInMainWorld("armcord", {
|
||||
window: {
|
||||
show: () => ipcRenderer.send("win-show"),
|
||||
hide: () => ipcRenderer.send("win-hide"),
|
||||
minimize: () => ipcRenderer.send("win-minimize"),
|
||||
maximize: () => ipcRenderer.send("win-maximize"),
|
||||
maximize: () => ipcRenderer.send("win-maximize")
|
||||
},
|
||||
titlebar: {
|
||||
injectTitlebar: () => injectTitlebar(),
|
||||
isTitlebar: ipcRenderer.sendSync("titlebar"),
|
||||
isTitlebar: ipcRenderer.sendSync("titlebar")
|
||||
},
|
||||
electron: process.versions.electron,
|
||||
channel: ipcRenderer.sendSync("channel"),
|
||||
openTab: (number: number) => ipcRenderer.sendSync("openTab", number),
|
||||
version: ipcRenderer.sendSync("get-app-version", "app-version"),
|
||||
getDisplayMediaSelector: getDisplayMediaSelector,
|
||||
openSettingsWindow: () => ipcRenderer.send("openSettingsWindow"),
|
||||
openSettingsWindow: () => ipcRenderer.send("openSettingsWindow")
|
||||
});
|
||||
//to be only used inside armcord internal setup/splash etc
|
||||
if (
|
||||
window.location.href.indexOf("splash.html") > -1 ||
|
||||
window.location.href.indexOf("setup.html") > -1
|
||||
) {
|
||||
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
|
||||
contextBridge.exposeInMainWorld("armcordinternal", {
|
||||
restart: () => ipcRenderer.send("restart"),
|
||||
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
|
||||
//original https://github.com/electron/electron/issues/16513#issuecomment-602070250
|
||||
import { ipcRenderer } from 'electron';
|
||||
import {addStyle, addScript} from '../utils';
|
||||
import {ipcRenderer} from "electron";
|
||||
import {addStyle, addScript} from "../utils";
|
||||
const desktopCapturer = {
|
||||
getSources: (opts: any) =>
|
||||
ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts),
|
||||
getSources: (opts: any) => ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts)
|
||||
};
|
||||
const CANCEL_ID = 'desktop-capturer-selection__cancel';
|
||||
const CANCEL_ID = "desktop-capturer-selection__cancel";
|
||||
|
||||
interface IPCSources {
|
||||
id: string;
|
||||
|
@ -16,22 +15,22 @@ interface IPCSources {
|
|||
|
||||
export async function getDisplayMediaSelector() {
|
||||
const sources: IPCSources[] = await desktopCapturer.getSources({
|
||||
types: ['screen', 'window'],
|
||||
types: ["screen", "window"]
|
||||
});
|
||||
return `<div class="desktop-capturer-selection__scroller">
|
||||
<ul class="desktop-capturer-selection__list">
|
||||
${sources
|
||||
.map(
|
||||
({ id, name, thumbnail }) => `
|
||||
({id, name, thumbnail}) => `
|
||||
<li class="desktop-capturer-selection__item">
|
||||
<button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
|
||||
<img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" />
|
||||
<span class="desktop-capturer-selection__name">${name}</span>
|
||||
</button>
|
||||
</li>
|
||||
`,
|
||||
`
|
||||
)
|
||||
.join('')}
|
||||
.join("")}
|
||||
<li class="desktop-capturer-selection__item">
|
||||
<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>
|
||||
|
@ -154,9 +153,8 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve
|
|||
});
|
||||
`;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
addScript(screenShareJS);
|
||||
addStyle(screenShareCSS);
|
||||
console.log("Capturer injected.")
|
||||
console.log("Capturer injected.");
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// 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
|
||||
// This is completely optional and is disabled by default in settings
|
||||
import { ipcRenderer } from "electron";
|
||||
import { injectJS } from "../utils";
|
||||
import {ipcRenderer} from "electron";
|
||||
import {injectJS} from "../utils";
|
||||
|
||||
var patchEndpoint = "https://patch.armcord.xyz/";
|
||||
var version = ipcRenderer.sendSync("get-app-version", "app-version");
|
||||
|
@ -15,7 +15,7 @@ if (ipcRenderer.sendSync("shouldPatch")) {
|
|||
console.log("Found a patch. Injecting...");
|
||||
injectJS(patchEndpoint + version + "/patch.js");
|
||||
} else {
|
||||
console.log("No patches have been found.")
|
||||
console.log("No patches have been found.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import "./bridge";
|
||||
import "./capturer";
|
||||
import "./patch"
|
||||
import "./patch";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { injectTitlebar } from "./titlebar";
|
||||
import { sleep, addStyle, injectJS } from "../utils";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { injectTabs } from "./tabs";
|
||||
import {injectTitlebar} from "./titlebar";
|
||||
import {sleep, addStyle, injectJS} from "../utils";
|
||||
import {ipcRenderer} from "electron";
|
||||
import {injectTabs} from "./tabs";
|
||||
declare global {
|
||||
interface Window {
|
||||
armcord: any;
|
||||
|
@ -14,9 +14,8 @@ declare global {
|
|||
}
|
||||
const clientMods = {
|
||||
goosemod: "https://api.goosemod.com/inject.js",
|
||||
cumcord:
|
||||
"https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js",
|
||||
flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js",
|
||||
cumcord: "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js",
|
||||
flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js"
|
||||
};
|
||||
|
||||
console.log("ArmCord");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { addStyle } from "../utils";
|
||||
import {addStyle} from "../utils";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
export function injectTabs() {
|
||||
|
@ -22,4 +22,5 @@ export function injectTabs() {
|
|||
}
|
||||
const cssPath = path.join(__dirname, "../", "/content/css/tabs.css");
|
||||
addStyle(fs.readFileSync(cssPath, "utf8"));
|
||||
})}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ipcRenderer } from "electron";
|
||||
import { addStyle } from "../utils";
|
||||
import {ipcRenderer} from "electron";
|
||||
import {addStyle} from "../utils";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
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 {getConfigUnsafe, saveSettings, Settings} from "../utils";
|
||||
import path from "path";
|
||||
var settings:any;
|
||||
var isAlreadyCreated:boolean = false;
|
||||
var settings: any;
|
||||
var isAlreadyCreated: boolean = false;
|
||||
storage.get("settings", function (error, data: any) {
|
||||
if (error) throw error;
|
||||
console.log(data);
|
||||
settings = data;
|
||||
});
|
||||
var settingsWindow:BrowserWindow;
|
||||
var settingsWindow: BrowserWindow;
|
||||
export function createSettingsWindow() {
|
||||
if (isAlreadyCreated) {
|
||||
settingsWindow.show();
|
||||
|
@ -22,8 +22,8 @@ export function createSettingsWindow() {
|
|||
frame: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
},
|
||||
preload: path.join(__dirname, "preload.js")
|
||||
}
|
||||
});
|
||||
ipcMain.on("saveSettings", (event, args: Settings) => {
|
||||
console.log(args);
|
||||
|
@ -32,15 +32,15 @@ export function createSettingsWindow() {
|
|||
ipcMain.handle("getSetting", (event, toGet: string) => {
|
||||
return getConfigUnsafe(toGet);
|
||||
});
|
||||
settingsWindow.webContents.setWindowOpenHandler(({ url }) => {
|
||||
settingsWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||
shell.openExternal(url);
|
||||
return { action: "deny" };
|
||||
return {action: "deny"};
|
||||
});
|
||||
settingsWindow.loadURL(`file://${__dirname}/settings.html`);
|
||||
settingsWindow.on("close", async (e) => {
|
||||
e.preventDefault()
|
||||
settingsWindow.hide()
|
||||
e.preventDefault();
|
||||
settingsWindow.hide();
|
||||
});
|
||||
isAlreadyCreated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import {contextBridge, ipcRenderer} from "electron";
|
||||
console.log("ArmCord Settings")
|
||||
console.log("ArmCord Settings");
|
||||
contextBridge.exposeInMainWorld("settings", {
|
||||
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;
|
||||
}
|
||||
.left {
|
||||
float:right;
|
||||
vertical-align: right!important;
|
||||
float: right;
|
||||
vertical-align: right !important;
|
||||
}
|
||||
.switch {
|
||||
vertical-align: middle;
|
||||
|
@ -87,13 +87,31 @@ button:hover {
|
|||
.tgl {
|
||||
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;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
.tgl + .tgl-btn {
|
||||
|
@ -108,7 +126,8 @@ button:hover {
|
|||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.tgl + .tgl-btn:after, .tgl + .tgl-btn:before {
|
||||
.tgl + .tgl-btn:after,
|
||||
.tgl + .tgl-btn:before {
|
||||
position: relative;
|
||||
display: block;
|
||||
content: "";
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>ArmCord Settings</title>
|
||||
<style>
|
||||
@import url("settings.css");
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="switch">
|
||||
<body>
|
||||
<div class="switch">
|
||||
<select name="theme" id="theme" class="left">
|
||||
<option value="default">Default</option>
|
||||
<option value="native">Native</option>
|
||||
|
@ -20,19 +18,19 @@
|
|||
</select>
|
||||
<p class="header">ArmCord theme:</p>
|
||||
</div>
|
||||
</br>
|
||||
<br />
|
||||
<div class="switch">
|
||||
<label class="header">ArmCord CSP</label>
|
||||
<input class="tgl tgl-light left" id="csp" type="checkbox" />
|
||||
<label class="tgl-btn left" for="csp"></label>
|
||||
</div>
|
||||
</br>
|
||||
<br />
|
||||
<div class="switch">
|
||||
<label class="header">Minimize to tray</label>
|
||||
<input class="tgl tgl-light left" id="tray" type="checkbox" />
|
||||
<label class="tgl-btn left" for="tray"></label>
|
||||
</div>
|
||||
</br>
|
||||
<br />
|
||||
<div class="switch">
|
||||
<label class="header">Automatic Patches</label>
|
||||
<input class="tgl tgl-light left" id="patches" type="checkbox" />
|
||||
|
@ -65,10 +63,9 @@
|
|||
<p class="header">Glasstron blur type:</p>
|
||||
</div>
|
||||
<button id="save" class="center">Save settings</button>
|
||||
</body>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
async function loadSettings() {
|
||||
document.getElementById("csp").checked = await settings.get("armcordCSP");
|
||||
document.getElementById("tray").checked = await settings.get("minimizeToTray");
|
||||
|
@ -78,11 +75,18 @@
|
|||
document.getElementById("theme").value = await settings.get("windowStyle");
|
||||
document.getElementById("blurType").value = await settings.get("blurType");
|
||||
}
|
||||
loadSettings()
|
||||
document.getElementById("save").addEventListener("click", function() {
|
||||
loadSettings();
|
||||
document.getElementById("save").addEventListener("click", function () {
|
||||
//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>
|
|
@ -1,11 +1,11 @@
|
|||
import { app } from "electron";
|
||||
import {mainWindow} from './window';
|
||||
import {app} from "electron";
|
||||
import {mainWindow} from "./window";
|
||||
//https://github.com/electron/electron/issues/1334#issuecomment-716080005
|
||||
// TO-DO add more
|
||||
app.on("web-contents-created", (webContentsCreatedEvent, webContents) => {
|
||||
webContents.on("before-input-event", (beforeInputEvent, input) => {
|
||||
// console.log('Main console::', input)
|
||||
const { code, alt, control, shift, meta } = input;
|
||||
const {code, alt, control, shift, meta} = input;
|
||||
// Shortcut: toggle devTools
|
||||
if (shift && control && !alt && !meta && code === "KeyI") {
|
||||
mainWindow.webContents.toggleDevTools();
|
||||
|
|
28
src/tray.ts
28
src/tray.ts
|
@ -1,38 +1,38 @@
|
|||
import { app, Menu, Tray } from 'electron';
|
||||
import {mainWindow} from './window';
|
||||
import * as path from 'path'
|
||||
import { createSettingsWindow } from './settings/main';
|
||||
let tray = null
|
||||
import {app, Menu, Tray} from "electron";
|
||||
import {mainWindow} from "./window";
|
||||
import * as path from "path";
|
||||
import {createSettingsWindow} from "./settings/main";
|
||||
let tray = null;
|
||||
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([
|
||||
{
|
||||
label: "Open ArmCord",
|
||||
click: function () {
|
||||
mainWindow.show();
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Open Settings",
|
||||
click: function () {
|
||||
createSettingsWindow();
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Support Discord Server",
|
||||
click: function () {
|
||||
mainWindow.show();
|
||||
mainWindow.loadURL("https://discord.gg/pZtWQBFjk6");
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Quit ArmCord",
|
||||
click: function () {
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
tray.setToolTip('ArmCord ' + app.getVersion())
|
||||
tray.setContextMenu(contextMenu)
|
||||
})
|
||||
tray.setToolTip("ArmCord " + app.getVersion());
|
||||
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 delayReadyEvent(): void;
|
||||
}
|
||||
export type WindowsBlurType =
|
||||
| "acrylic"
|
||||
| "blurbehind"
|
||||
| "transparent"
|
||||
| "none";
|
||||
export type WindowsBlurType = "acrylic" | "blurbehind" | "transparent" | "none";
|
||||
export type MacOSVibrancy =
|
||||
| (
|
||||
| "appearance-based"
|
||||
|
@ -63,24 +59,12 @@ declare module "glasstron" {
|
|||
declare module "glasstron/src/utils" {
|
||||
class Utils {
|
||||
static getSavePath(): string;
|
||||
static copyToPath(
|
||||
innerFile: string,
|
||||
outerFilename?: string,
|
||||
flags?: number
|
||||
): void;
|
||||
static copyToPath(innerFile: string, outerFilename?: string, flags?: number): void;
|
||||
static removeFromPath(filename: string): void;
|
||||
static isInPath(filename: string): boolean;
|
||||
static getPlatform(): any;
|
||||
static parseKeyValString(
|
||||
string: string,
|
||||
keyvalSeparator?: string,
|
||||
pairSeparator?: string
|
||||
): any;
|
||||
static makeKeyValString(
|
||||
object: any,
|
||||
keyvalSeparator?: string,
|
||||
pairSeparator?: string
|
||||
): string;
|
||||
static parseKeyValString(string: string, keyvalSeparator?: string, pairSeparator?: string): any;
|
||||
static makeKeyValString(object: any, keyvalSeparator?: string, pairSeparator?: string): string;
|
||||
}
|
||||
export = Utils;
|
||||
}
|
||||
|
|
28
src/utils.ts
28
src/utils.ts
|
@ -1,6 +1,6 @@
|
|||
import * as storage from "electron-json-storage";
|
||||
import * as fs from "fs";
|
||||
import { app } from "electron";
|
||||
import {app} from "electron";
|
||||
import path from "path";
|
||||
export var firstRun: boolean;
|
||||
|
||||
|
@ -22,19 +22,19 @@ export async function sleep(ms: number) {
|
|||
}
|
||||
|
||||
export async function checkIfConfigIsNew() {
|
||||
if (await getConfigUnsafe("automaticPatches") == undefined) {
|
||||
if ((await getConfigUnsafe("automaticPatches")) == undefined) {
|
||||
firstRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
windowStyle: string,
|
||||
channel: string,
|
||||
armcordCSP: boolean,
|
||||
minimizeToTray: boolean,
|
||||
automaticPatches: boolean,
|
||||
mods: string,
|
||||
blurType: string
|
||||
windowStyle: string;
|
||||
channel: string;
|
||||
armcordCSP: boolean;
|
||||
minimizeToTray: boolean;
|
||||
automaticPatches: boolean;
|
||||
mods: string;
|
||||
blurType: string;
|
||||
}
|
||||
export function setup() {
|
||||
console.log("Setting up temporary ArmCord settings.");
|
||||
|
@ -45,13 +45,13 @@ export function setup() {
|
|||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: "cumcord",
|
||||
blurType: "acrylic",
|
||||
}
|
||||
blurType: "acrylic"
|
||||
};
|
||||
storage.set(
|
||||
"settings",
|
||||
{
|
||||
...defaults,
|
||||
doneSetup: true,
|
||||
doneSetup: true
|
||||
},
|
||||
function (error) {
|
||||
if (error) throw error;
|
||||
|
@ -59,9 +59,7 @@ export function setup() {
|
|||
);
|
||||
}
|
||||
|
||||
export function saveSettings(
|
||||
settings: Settings
|
||||
) {
|
||||
export function saveSettings(settings: Settings) {
|
||||
console.log("Setting up ArmCord settings.");
|
||||
storage.set(
|
||||
"settings",
|
||||
|
|
|
@ -2,21 +2,20 @@
|
|||
// 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
|
||||
// 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 { contentPath } from "./main";
|
||||
import { checkIfConfigIsNew, firstRun, getConfigUnsafe } from "./utils";
|
||||
import { registerIpc } from "./ipc";
|
||||
import {contentPath} from "./main";
|
||||
import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils";
|
||||
import {registerIpc} from "./ipc";
|
||||
import contextMenu from "electron-context-menu";
|
||||
export let mainWindow: BrowserWindow;
|
||||
import * as glasstron from "glasstron";
|
||||
|
||||
let guestWindows: BrowserWindow [] = [];
|
||||
let guestWindows: BrowserWindow[] = [];
|
||||
contextMenu({
|
||||
showSaveImageAs: true,
|
||||
showCopyImageAddress: true,
|
||||
showSearchWithGoogle: true,
|
||||
|
||||
showSearchWithGoogle: true
|
||||
});
|
||||
|
||||
function doAfterDefiningTheWindow() {
|
||||
|
@ -24,25 +23,22 @@ function doAfterDefiningTheWindow() {
|
|||
registerIpc();
|
||||
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
|
||||
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
||||
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||
shell.openExternal(url);
|
||||
return { action: "deny" };
|
||||
return {action: "deny"};
|
||||
});
|
||||
mainWindow.webContents.session.webRequest.onBeforeRequest(
|
||||
(details, callback) => {
|
||||
if (/api\/v\d\/science$/g.test(details.url))
|
||||
return callback({ cancel: true });
|
||||
mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
|
||||
if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true});
|
||||
return callback({});
|
||||
}
|
||||
);
|
||||
});
|
||||
mainWindow.on("close", async (e) => {
|
||||
if (await getConfigUnsafe("minimizeToTray")) {
|
||||
e.preventDefault();
|
||||
mainWindow.hide();
|
||||
} else if (!await getConfigUnsafe("minimizeToTray")) {
|
||||
} else if (!(await getConfigUnsafe("minimizeToTray"))) {
|
||||
e.preventDefault();
|
||||
app.exit();
|
||||
app.quit()
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
console.log(contentPath);
|
||||
|
@ -79,8 +75,8 @@ export function createCustomWindow() {
|
|||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload/preload.js"),
|
||||
spellcheck: true,
|
||||
},
|
||||
spellcheck: true
|
||||
}
|
||||
});
|
||||
doAfterDefiningTheWindow();
|
||||
}
|
||||
|
@ -95,8 +91,8 @@ export function createNativeWindow() {
|
|||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload/preload.js"),
|
||||
spellcheck: true,
|
||||
},
|
||||
spellcheck: true
|
||||
}
|
||||
});
|
||||
doAfterDefiningTheWindow();
|
||||
}
|
||||
|
@ -111,8 +107,8 @@ export function createGlasstronWindow() {
|
|||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload/preload.js"),
|
||||
spellcheck: true,
|
||||
},
|
||||
spellcheck: true
|
||||
}
|
||||
});
|
||||
|
||||
//@ts-expect-error
|
||||
|
@ -132,17 +128,17 @@ export function createTabsHost() {
|
|||
frame: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload/preload.js"),
|
||||
},
|
||||
preload: path.join(__dirname, "preload/preload.js")
|
||||
}
|
||||
});
|
||||
doAfterDefiningTheWindow();
|
||||
}
|
||||
export function createTabsGuest(number: number) {
|
||||
console.log(guestWindows)
|
||||
console.log(guestWindows);
|
||||
if (guestWindows[number] !== undefined || null) {
|
||||
try {
|
||||
console.log("Showing Guest Window " + number);
|
||||
mainWindow.hide()
|
||||
mainWindow.hide();
|
||||
guestWindows[number].show();
|
||||
mainWindow = guestWindows[number];
|
||||
} catch (e) {
|
||||
|
@ -161,8 +157,8 @@ export function createTabsGuest(number: number) {
|
|||
frame: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, "preload/preload.js"),
|
||||
},
|
||||
preload: path.join(__dirname, "preload/preload.js")
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow = guestWindows[number];
|
||||
|
@ -173,18 +169,14 @@ export function createTabsGuest(number: number) {
|
|||
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
|
||||
|
||||
guestWindows[number].webContents.setWindowOpenHandler(({ url }) => {
|
||||
guestWindows[number].webContents.setWindowOpenHandler(({url}) => {
|
||||
shell.openExternal(url);
|
||||
return { action: "deny" };
|
||||
return {action: "deny"};
|
||||
});
|
||||
|
||||
guestWindows[number].webContents.session.webRequest.onBeforeRequest(
|
||||
(
|
||||
details: { url: string },
|
||||
callback: (arg0: { cancel?: boolean }) => any
|
||||
) => {
|
||||
if (/api\/v\d\/science$/g.test(details.url))
|
||||
return callback({ cancel: true });
|
||||
(details: {url: string}, callback: (arg0: {cancel?: boolean}) => any) => {
|
||||
if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true});
|
||||
return callback({});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue