Skip to content
Open
6 changes: 6 additions & 0 deletions browser/VencordNativeStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ window.VencordNative = {

pluginHelpers: {} as any,
csp: {} as any,
tray: {
setUpdateState: NOOP,
onCheckUpdates: NOOP,
onRepair: NOOP,
onAbout: NOOP,
},
};
36 changes: 35 additions & 1 deletion src/Vencord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export * as Webpack from "./webpack";
export * as WebpackPatcher from "./webpack/patchWebpack";
export { PlainSettings, Settings };

import { popNotice, showNotice } from "@api/Notices";
import { coreStyleRootNode, initStyles } from "@api/Styles";
import { openSettingsTabModal, UpdaterTab } from "@components/settings";
import { debounce } from "@shared/debounce";
Expand All @@ -43,7 +44,7 @@ import { PlainSettings, Settings, SettingsStore } from "./api/Settings";
import { getCloudSettings, putCloudSettings, shouldCloudSync } from "./api/SettingsSync/cloudSync";
import { localStorage } from "./utils/localStorage";
import { relaunch } from "./utils/native";
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
import { checkForUpdates, isOutdated as getIsOutdated, update, UpdateLogger } from "./utils/updater";
import { onceReady } from "./webpack";
import { patches } from "./webpack/patchWebpack";

Expand Down Expand Up @@ -124,6 +125,7 @@ async function runUpdateCheck() {

try {
const isOutdated = await checkForUpdates();
if (IS_DISCORD_DESKTOP) VencordNative.tray.setUpdateState(isOutdated);
if (!isOutdated) return;

if (Settings.autoUpdate) {
Expand All @@ -148,11 +150,43 @@ async function runUpdateCheck() {
}
}

function initTrayIpc() {
if (IS_WEB || IS_UPDATER_DISABLED) return;

VencordNative.tray.onCheckUpdates(async () => {
try {
const isOutdated = await checkForUpdates();
VencordNative.tray.setUpdateState(isOutdated);

if (isOutdated) {
showNotice("An Vencord update is available!", "View Update", () => openSettingsTabModal(UpdaterTab!));
} else {
showNotice("No updates available, you're on the latest version!", "OK", popNotice);
}
} catch (err) {
UpdateLogger.error("Failed to check for updates from tray", err);
showNotice("Failed to check for updates, check the console for more info", "OK", popNotice);
}
});

VencordNative.tray.onRepair(async () => {
try {
await update();
relaunch();
} catch (err) {
UpdateLogger.error("Failed to repair Vencord", err);
}
});

VencordNative.tray.setUpdateState(getIsOutdated);
}

async function init() {
await onceReady;
startAllPlugins(StartAt.WebpackReady);

syncSettings();
initTrayIpc();

if (!IS_WEB && !IS_UPDATER_DISABLED) {
runUpdateCheck();
Expand Down
7 changes: 7 additions & 0 deletions src/VencordNative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,12 @@ export default {
invoke<CspRequestResult>(IpcEvents.CSP_REQUEST_ADD_OVERRIDE, url, directives, callerName),
},

tray: {
setUpdateState: (available: boolean) => ipcRenderer.send(IpcEvents.SET_TRAY_UPDATE_STATE, available),
onCheckUpdates: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_CHECK_UPDATES, cb); },
onRepair: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_REPAIR, cb); },
onAbout: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_ABOUT, cb); },
},

pluginHelpers: PluginHelpers
};
173 changes: 173 additions & 0 deletions src/main/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<!doctype html>
<meta charset="utf-8" />

<head>
<title>About Vencord</title>
<style>
body {
padding: 2em;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
"Open Sans", "Helvetica Neue", sans-serif;
margin: 0;
}

:root {
--bg: #282828;
--fg: #d4be98;
--fg-secondary: #ddc7a0;
}

html,
body {
background: var(--bg);
color: var(--fg);
}

.header {
display: flex;
align-items: center;
gap: 1.25em;
margin-bottom: 2em;
}

.header img {
width: 48px;
height: 48px;
border-radius: 8px;
}

.header-text {
display: flex;
flex-direction: column;
gap: 0.25em;
}

.header-top {
display: flex;
align-items: baseline;
gap: 0.5em;
}

.header-text h1 {
margin: 0;
font-size: 1.75em;
font-weight: 700;
color: var(--fg);
}

.header-text .version {
color: var(--fg-secondary);
font-size: 0.875em;
}

.header-text .tagline {
color: var(--fg-secondary);
margin: 0;
}

h2 {
color: var(--fg);
margin-top: 1.5em;
margin-bottom: 0.5em;
}

p {
color: var(--fg-secondary);
}

ul {
display: flex;
flex-direction: column;
gap: 0.5em;
padding-left: 1.5em;
}

li {
color: var(--fg-secondary);
}

a {
color: var(--fg-secondary);
text-decoration: underline;
transition: color 0.2s linear;
}

a:hover {
color: var(--fg);
}

section {
margin-bottom: 1.5em;
}
</style>
</head>

<body>
<header class="header">
<img src="https://vencord.dev/assets/favicon-dark.png" alt="Vencord" />
<div class="header-text">
<div class="header-top">
<h1>Vencord</h1>
<span class="version">
<a href="https://github.com/Vendicated/Vencord/releases/tag/v{{VERSION}}">
v{{VERSION}}
</a>
(<a href="https://github.com/Vendicated/Vencord/commit/{{GIT_HASH}}">{{GIT_HASH}}</a>)
</span>

</div>
<p class="tagline">
A lightweight, user friendly Discord mod focused on privacy and stability.
</p>
</div>
</header>

<section>
<h2>Links</h2>
<ul>
<li>
<a href="https://vencord.dev" target="_blank">Vencord Website</a>
</li>
<li>
<a href="https://docs.vencord.dev" target="_blank">Vencord Docs</a>
</li>
<li>
<a href="https://github.com/Vendicated/Vencord" target="_blank">Source Code</a>
</li>
<li>
<a href="https://vencord.dev/discord" target="_blank">Support Server</a>
</li>
</ul>
</section>
<section>
<h2>License</h2>
<p>
Vencord is licensed under the
<a href="https://www.gnu.org/licenses/gpl-3.0.txt" target="_blank">GNU General Public License v3.0</a>.
<br />
This is free software, and you are welcome to redistribute it under certain conditions; see the license for
details.
</p>
</section>
</body>
<script>
const data = new URLSearchParams(location.search);

// replace all {{FOO}} placeholders in the document with the values from the URL

/** @param {Node} [node] */
function walk(node) {
if (node.nodeType === Node.TEXT_NODE) {
node.textContent = node.textContent.replace(/{{(\w+)}}/g, (match, key) => data.get(key) || match);
return;
}

if (node.nodeType === Node.ELEMENT_NODE && node.nodeName !== "SCRIPT") {
for (const child of node.childNodes) {
walk(child);
}
}
}

walk(document.body);
</script>
4 changes: 4 additions & 0 deletions src/main/patcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron";
import { dirname, join } from "path";

import { RendererSettings } from "./settings";
import { patchTrayMenu } from "./trayMenu";
import { IS_VANILLA } from "./utils/constants";

console.log("[Vencord] Starting up...");
Expand All @@ -42,6 +43,9 @@ app.setAppPath(asarPath);

if (!IS_VANILLA) {
const settings = RendererSettings.store;

patchTrayMenu();

// Repatch after host updates on Windows
if (process.platform === "win32") {
require("./patchWin32Updater");
Expand Down
Loading
Loading