parent
18bebfb421
commit
87920505db
|
@ -0,0 +1 @@
|
|||
_
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
. "$(dirname $0)/_/husky.sh"
|
||||
|
||||
npm run format
|
||||
git add -A
|
|
@ -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
|
|
@ -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": {
|
||||
|
|
|
@ -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"
|
||||
};
|
|
@ -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) {
|
||||
|
@ -54,16 +53,13 @@ const unstrictCSP = () => {
|
|||
}
|
||||
|
||||
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,5 +1,5 @@
|
|||
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)) {
|
||||
|
@ -9,16 +9,10 @@ if (!fs.existsSync(pluginFolder)) {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
12
src/main.ts
12
src/main.ts
|
@ -1,9 +1,5 @@
|
|||
// 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";
|
||||
|
@ -19,7 +15,7 @@ export var settings: any;
|
|||
export var customTitlebar: boolean;
|
||||
export var tabs: boolean;
|
||||
async function appendSwitch() {
|
||||
if (await getConfigUnsafe("windowStyle") == "glasstron") {
|
||||
if ((await getConfigUnsafe("windowStyle")) == "glasstron") {
|
||||
console.log("Enabling transparency visuals.");
|
||||
app.commandLine.appendSwitch("enable-transparent-visuals");
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -7,27 +7,24 @@ contextBridge.exposeInMainWorld("armcord", {
|
|||
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,7 +15,7 @@ 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">
|
||||
|
@ -29,9 +28,9 @@ export async function getDisplayMediaSelector() {
|
|||
<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>
|
||||
|
@ -157,6 +156,5 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve
|
|||
document.addEventListener("DOMContentLoaded", function () {
|
||||
addScript(screenShareJS);
|
||||
addStyle(screenShareCSS);
|
||||
console.log("Capturer injected.")
|
||||
console.log("Capturer injected.");
|
||||
});
|
||||
|
||||
|
|
|
@ -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,6 +1,6 @@
|
|||
import "./bridge";
|
||||
import "./capturer";
|
||||
import "./patch"
|
||||
import "./patch";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import {injectTitlebar} from "./titlebar";
|
||||
|
@ -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");
|
||||
|
|
|
@ -22,4 +22,5 @@ export function injectTabs() {
|
|||
}
|
||||
const cssPath = path.join(__dirname, "../", "/content/css/tabs.css");
|
||||
addStyle(fs.readFileSync(cssPath, "utf8"));
|
||||
})}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -38,8 +38,8 @@ export function createSettingsWindow() {
|
|||
});
|
||||
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
|
||||
});
|
|
@ -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,6 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>ArmCord Settings</title>
|
||||
|
@ -10,7 +9,6 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="switch">
|
||||
<select name="theme" id="theme" class="left">
|
||||
<option value="default">Default</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,7 +63,6 @@
|
|||
<p class="header">Glasstron blur type:</p>
|
||||
</div>
|
||||
<button id="save" class="center">Save settings</button>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
@ -78,11 +75,18 @@
|
|||
document.getElementById("theme").value = await settings.get("windowStyle");
|
||||
document.getElementById("blurType").value = await settings.get("blurType");
|
||||
}
|
||||
loadSettings()
|
||||
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>
|
||||
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
import {app} from "electron";
|
||||
import {mainWindow} from './window';
|
||||
import {mainWindow} from "./window";
|
||||
//https://github.com/electron/electron/issues/1334#issuecomment-716080005
|
||||
// TO-DO add more
|
||||
app.on("web-contents-created", (webContentsCreatedEvent, webContents) => {
|
||||
|
|
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);
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
26
src/utils.ts
26
src/utils.ts
|
@ -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",
|
||||
|
|
|
@ -15,8 +15,7 @@ let guestWindows: BrowserWindow [] = [];
|
|||
contextMenu({
|
||||
showSaveImageAs: true,
|
||||
showCopyImageAddress: true,
|
||||
showSearchWithGoogle: true,
|
||||
|
||||
showSearchWithGoogle: true
|
||||
});
|
||||
|
||||
function doAfterDefiningTheWindow() {
|
||||
|
@ -28,21 +27,18 @@ function doAfterDefiningTheWindow() {
|
|||
shell.openExternal(url);
|
||||
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];
|
||||
|
@ -179,12 +175,8 @@ export function createTabsGuest(number: number) {
|
|||
});
|
||||
|
||||
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 New Issue