Compare commits

...

21 Commits

Author SHA1 Message Date
V
bea7a1711e Bump to v1.3.4 2023-07-08 03:40:31 +02:00
Lewis Crichton
e52ae62441 feat(cloud): support multiple user accounts (#1382)
Co-authored-by: V <vendicated@riseup.net>
2023-07-08 03:36:59 +02:00
V
7cd1d4c60f translate: Add context menu item; fix MLE compatibility 2023-07-08 03:30:16 +02:00
V
2a318e390e QuickCss: Fix wrongly applying quickcss when editing while disabled 2023-07-08 03:13:32 +02:00
V
7c7723bfb1 Plugin Settings: Use Switches for booleans 2023-07-08 03:04:58 +02:00
dolfies
2db0e71e5b fix(RelationshipNotifier): Ignore user-actioned friend requests (#1390) 2023-07-08 02:37:32 +02:00
Ryan Cao
cde8074f44 feat(ClearURLs): add Threads share link tracking param (#1384) 2023-07-08 02:34:16 +02:00
Nuckyz
8b1630bc99 Fix ShowAllMessageButtons (#1392)
Co-authored-by: V <vendicated@riseup.net>
2023-07-08 02:33:37 +02:00
V
bf34b2ae43 Bump to v1.3.3 2023-07-06 01:26:31 +02:00
V
cb5f23d9b5 ProxyLazy: Limit attempts 2023-07-06 00:54:49 +02:00
V
cd2cbfa0ef ShowHiddenChannels: Fix crashing on canary 2023-07-06 00:43:43 +02:00
Ryan Cao
232e340fab fix: send notification when settings are manually synced (#1378)
Co-authored-by: V <vendicated@riseup.net>
2023-07-04 15:59:42 +00:00
V
8027daa2b0 Fix types 2023-07-04 17:58:32 +02:00
Ryan Cao
0f7b9f588e perf(cloud sync): minify synced settings (#1377) 2023-07-04 17:57:28 +02:00
V
93482ac2a5 SpotifyControls: improve open in app capabilities & styles 2023-07-04 17:53:17 +02:00
V
994c3b3c92 OpenInApp: Fix bot buttons 2023-07-04 17:52:52 +02:00
V
c696c186e8 WebKeybinds: Fix scope 2023-07-02 01:23:51 +02:00
V
30d5e2108f Bump to 1.3.2 2023-07-02 01:22:53 +02:00
V
1eabd1b701 WebKeybinds: Fix broken zoom on vesktop 2023-07-02 01:22:37 +02:00
V
1cbf2b43e1 Fix Badges 2023-07-02 01:17:02 +02:00
V
4c197d5d51 New Plugin: WebKeyBinds 2023-07-02 01:08:06 +02:00
20 changed files with 227 additions and 78 deletions

View File

@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.3.1",
"version": "1.3.4",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {

View File

@ -16,8 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { wordsFromCamel, wordsToTitle } from "@utils/text";
import { PluginOptionBoolean } from "@utils/types";
import { Forms, React, Select } from "@webpack/common";
import { Forms, React, Switch } from "@webpack/common";
import { ISettingElementProps } from ".";
@ -31,11 +32,6 @@ export function SettingBooleanComponent({ option, pluginSettings, definedSetting
onError(error !== null);
}, [error]);
const options = [
{ label: "Enabled", value: true, default: def === true },
{ label: "Disabled", value: false, default: typeof def === "undefined" || def === false },
];
function handleChange(newValue: boolean): void {
const isValid = option.isValid?.call(definedSettings, newValue) ?? true;
if (typeof isValid === "string") setError(isValid);
@ -49,18 +45,17 @@ export function SettingBooleanComponent({ option, pluginSettings, definedSetting
return (
<Forms.FormSection>
<Forms.FormTitle>{option.description}</Forms.FormTitle>
<Select
isDisabled={option.disabled?.call(definedSettings) ?? false}
options={options}
placeholder={option.placeholder ?? "Select an option"}
maxVisibleItems={5}
closeOnSelect={true}
select={handleChange}
isSelected={v => v === state}
serialize={v => String(v)}
<Switch
value={state}
onChange={handleChange}
note={option.description}
disabled={option.disabled?.call(definedSettings) ?? false}
{...option.componentProps}
/>
hideBorder
style={{ marginBottom: "0.5em" }}
>
{wordsToTitle(wordsFromCamel(id))}
</Switch>
{error && <Forms.FormText style={{ color: "var(--text-danger)" }}>{error}</Forms.FormText>}
</Forms.FormSection>
);

View File

@ -86,7 +86,7 @@ function SettingsSyncSection() {
<Button
size={Button.Sizes.SMALL}
disabled={!sectionEnabled}
onClick={() => putCloudSettings()}
onClick={() => putCloudSettings(true)}
>Sync to Cloud</Button>
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
{({ onMouseLeave, onMouseEnter }) => (

View File

@ -80,8 +80,8 @@ export default definePlugin({
find: "Messages.PROFILE_USER_BADGES,role:",
replacement: [
{
match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/,
replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`,
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
},
{
// alt: "", aria-hidden: false, src: originalSrc

View File

@ -135,4 +135,5 @@ export const defaultRules = [
"utm_campaign",
"utm_term",
"si@open.spotify.com",
"igshid",
];

View File

@ -20,7 +20,7 @@ import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { showToast, Toasts } from "@webpack/common";
import { MouseEvent } from "react";
import type { MouseEvent } from "react";
const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/;
@ -77,12 +77,12 @@ export default definePlugin({
}
],
async handleLink(data: { href: string; }, event: MouseEvent) {
async handleLink(data: { href: string; }, event?: MouseEvent) {
if (!data) return false;
let url = data.href;
if (!IS_WEB && ShortUrlMatcher.test(url)) {
event.preventDefault();
event?.preventDefault();
// CORS jumpscare
url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url);
}
@ -96,7 +96,7 @@ export default definePlugin({
const [, type, id] = match;
VencordNative.native.openExternal(`spotify:${type}:${id}`);
event.preventDefault();
event?.preventDefault();
return true;
}
@ -106,7 +106,7 @@ export default definePlugin({
if (!SteamMatcher.test(url)) break steam;
VencordNative.native.openExternal(`steam://openurl/${url}`);
event.preventDefault();
event?.preventDefault();
// Steam does not focus itself so show a toast so it's slightly less confusing
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
@ -120,13 +120,13 @@ export default definePlugin({
if (!match) break epic;
VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`);
event.preventDefault();
event?.preventDefault();
return true;
}
// in case short url didn't end up being something we can handle
if (event.defaultPrevented) {
if (event?.defaultPrevented) {
window.open(url, "_blank");
return true;
}

View File

@ -50,7 +50,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
() => openUserProfile(user.id)
);
break;
case RelationshipType.FRIEND_REQUEST:
case RelationshipType.INCOMING_REQUEST:
if (settings.store.friendRequestCancels)
notify(
`A friend request from ${getUniqueUsername(user)} has been removed.`,

View File

@ -58,5 +58,7 @@ export const enum ChannelType {
export const enum RelationshipType {
FRIEND = 1,
FRIEND_REQUEST = 3,
BLOCKED = 2,
INCOMING_REQUEST = 3,
OUTGOING_REQUEST = 4,
}

View File

@ -80,7 +80,10 @@ export async function syncAndRunChecks() {
if (settings.store.friendRequestCancels && oldFriends?.requests?.length) {
for (const id of oldFriends.requests) {
if (friends.requests.includes(id)) continue;
if (
friends.requests.includes(id) ||
[RelationshipType.FRIEND, RelationshipType.BLOCKED, RelationshipType.OUTGOING_REQUEST].includes(RelationshipStore.getRelationshipType(id))
) continue;
const user = await UserUtils.fetchUser(id).catch(() => void 0);
if (user)
@ -164,7 +167,7 @@ export async function syncFriends() {
case RelationshipType.FRIEND:
friends.friends.push(id);
break;
case RelationshipType.FRIEND_REQUEST:
case RelationshipType.INCOMING_REQUEST:
friends.requests.push(id);
break;
}

View File

@ -28,8 +28,8 @@ export default definePlugin({
{
find: ".Messages.MESSAGE_UTILITIES_A11Y_LABEL",
replacement: {
// isExpanded: V, (?<=,V = shiftKeyDown && !H...;)
match: /isExpanded:(\i),(?<=,\1=\i&&(!.+);.+?)/,
// isExpanded: V, (?<=,V = shiftKeyDown && !H...,|;)
match: /isExpanded:(\i),(?<=,\1=\i&&(?=(!.+?)[,;]).+?)/,
replace: "isExpanded:$2,"
}
}

View File

@ -29,7 +29,7 @@ import type { Channel, Role } from "discord-types/general";
import HiddenChannelLockScreen, { setChannelBeginHeaderComponent } from "./components/HiddenChannelLockScreen";
const ChannelListClasses = findByPropsLazy("channelName", "subtitle", "modeMuted", "iconContainer");
const ChannelListClasses = findByPropsLazy("channelEmoji", "unread", "icon");
export const VIEW_CHANNEL = 1n << 10n;
const CONNECT = 1n << 20n;
@ -472,7 +472,7 @@ export default definePlugin({
HiddenChannelLockScreen: (channel: any) => <HiddenChannelLockScreen channel={channel} />,
LockIcon: () => (
LockIcon: ErrorBoundary.wrap(() => (
<svg
className={ChannelListClasses.icon}
height="18"
@ -483,7 +483,7 @@ export default definePlugin({
>
<path className="shc-evenodd-fill-current-color" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
</svg>
),
), { noop: true }),
HiddenChannelIcon: ErrorBoundary.wrap(() => (
<Tooltip text="Hidden Channel">

View File

@ -21,7 +21,6 @@ import "./spotifyStyles.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
import { Link } from "@components/Link";
import { debounce } from "@utils/debounce";
import { openImageModal } from "@utils/discord";
import { classes, copyWithToast } from "@utils/misc";
@ -254,6 +253,16 @@ function AlbumContextMenu({ track }: { track: Track; }) {
);
}
function makeLinkProps(name: string, condition: unknown, path: string) {
if (!condition) return {};
return {
role: "link",
onClick: () => SpotifyStore.openExternal(path),
onContextMenu: makeContextMenu(name, path)
} satisfies React.HTMLAttributes<HTMLElement>;
}
function Info({ track }: { track: Track; }) {
const img = track?.album?.image;
@ -289,12 +298,8 @@ function Info({ track }: { track: Track; }) {
variant="text-sm/semibold"
id={cl("song-title")}
className={cl("ellipoverflow")}
role={track.id ? "link" : undefined}
title={track.name}
onClick={track.id ? () => {
SpotifyStore.openExternal(`/track/${track.id}`);
} : void 0}
onContextMenu={track.id ? makeContextMenu("Song", `/track/${track.id}`) : void 0}
{...makeLinkProps("Song", track.id, `/track/${track.id}`)}
>
{track.name}
</Forms.FormText>
@ -303,16 +308,14 @@ function Info({ track }: { track: Track; }) {
by&nbsp;
{track.artists.map((a, i) => (
<React.Fragment key={a.name}>
<Link
<span
className={cl("artist")}
disabled={!a.id}
href={`https://open.spotify.com/artist/${a.id}`}
style={{ fontSize: "inherit" }}
title={a.name}
onContextMenu={makeContextMenu("Artist", `/artist/${a.id}`)}
{...makeLinkProps("Artist", a.id, `/artist/${a.id}`)}
>
{a.name}
</Link>
</span>
{i !== track.artists.length - 1 && <span className={cl("comma")}>{", "}</span>}
</React.Fragment>
))}
@ -321,17 +324,15 @@ function Info({ track }: { track: Track; }) {
{track.album.name && (
<Forms.FormText variant="text-sm/normal" className={cl("ellipoverflow")}>
on&nbsp;
<Link id={cl("album-title")}
href={`https://open.spotify.com/album/${track.album.id}`}
target="_blank"
<span
id={cl("album-title")}
className={cl("album")}
disabled={!track.album.id}
style={{ fontSize: "inherit" }}
title={track.album.name}
onContextMenu={makeContextMenu("Album", `/album/${track.album.id}`)}
{...makeLinkProps("Album", track.album.id, `/album/${track.album.id}`)}
>
{track.album.name}
</Link>
</span>
</Forms.FormText>
)}
</div>

View File

@ -131,8 +131,8 @@
color: var(--header-secondary);
}
.vc-spotify-artist:hover,
#vc-spotify-album-title:hover,
.vc-spotify-artist[role="link"]:hover,
#vc-spotify-album-title[role="link"]:hover,
#vc-spotify-song-title[role="link"]:hover {
text-decoration: underline;
cursor: pointer;

View File

@ -44,6 +44,9 @@ export function TranslationAccessory({ message }: { message: Message; }) {
const [translation, setTranslation] = useState<TranslationValue>();
useEffect(() => {
// Ignore MessageLinkEmbeds messages
if ((message as any).vencordEmbeddedBy) return;
TranslationSetters.set(message.id, setTranslation);
return () => void TranslationSetters.delete(message.id);

View File

@ -18,19 +18,39 @@
import "./styles.css";
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
import { addAccessory, removeAccessory } from "@api/MessageAccessories";
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { addButton, removeButton } from "@api/MessagePopover";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { ChannelStore } from "@webpack/common";
import { ChannelStore, Menu } from "@webpack/common";
import { settings } from "./settings";
import { TranslateChatBarIcon, TranslateIcon } from "./TranslateIcon";
import { handleTranslate, TranslationAccessory } from "./TranslationAccessory";
import { translate } from "./utils";
const messageCtxPatch: NavContextMenuPatchCallback = (children, { message }) => () => {
if (!message.content) return;
const group = findGroupChildrenByChildId("copy-text", children);
if (!group) return;
group.splice(group.findIndex(c => c?.props?.id === "copy-text") + 1, 0, (
<Menu.MenuItem
id="vc-trans"
label="Translate"
icon={TranslateIcon}
action={async () => {
const trans = await translate("received", message.content);
handleTranslate(message.id, trans);
}}
/>
));
};
export default definePlugin({
name: "Translate",
description: "Translate messages with Google Translate",
@ -53,6 +73,8 @@ export default definePlugin({
start() {
addAccessory("vc-translation", props => <TranslationAccessory message={props.message} />);
addContextMenuPatch("message", messageCtxPatch);
addButton("vc-translate", message => {
if (!message.content) return null;
@ -78,6 +100,7 @@ export default definePlugin({
stop() {
removePreSendListener(this.preSend);
removeContextMenuPatch("message", messageCtxPatch);
removeButton("vc-translate");
removeAccessory("vc-translation");
},

View File

@ -0,0 +1,79 @@
/*
* Vencord, a modification for Discord's desktop app
* Copyright (c) 2023 Vendicated and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findLazy, mapMangledModuleLazy } from "@webpack";
import { ComponentDispatch, FluxDispatcher, NavigationRouter, SelectedGuildStore, SettingsRouter } from "@webpack/common";
const GuildNavBinds = mapMangledModuleLazy("mod+alt+down", {
CtrlTab: m => m.binds?.at(-1) === "ctrl+tab",
CtrlShiftTab: m => m.binds?.at(-1) === "ctrl+shift+tab",
});
const DigitBinds = findLazy(m => m.binds?.[0] === "mod+1");
export default definePlugin({
name: "WebKeybinds",
description: "Re-adds keybinds missing in the web version of Discord: ctrl+t, ctrl+shift+t, ctrl+tab, ctrl+shift+tab, ctrl+1-9, ctrl+,",
authors: [Devs.Ven],
enabledByDefault: true,
onKey(e: KeyboardEvent) {
const hasCtrl = e.ctrlKey || (e.metaKey && navigator.platform.includes("Mac"));
if (hasCtrl) switch (e.key) {
case "t":
case "T":
e.preventDefault();
if (e.shiftKey) {
if (SelectedGuildStore.getGuildId()) NavigationRouter.transitionToGuild("@me");
ComponentDispatch.safeDispatch("TOGGLE_DM_CREATE");
} else {
FluxDispatcher.dispatch({
type: "QUICKSWITCHER_SHOW",
query: "",
queryMode: null
});
}
break;
case ",":
e.preventDefault();
SettingsRouter.open("My Account");
break;
case "Tab":
const handler = e.shiftKey ? GuildNavBinds.CtrlShiftTab : GuildNavBinds.CtrlTab;
handler.action(e);
break;
default:
if (e.key >= "1" && e.key <= "9") {
e.preventDefault();
DigitBinds.action(e, `mod+${e.key}`);
}
break;
}
},
start() {
document.addEventListener("keydown", this.onKey);
},
stop() {
document.removeEventListener("keydown", this.onKey);
}
});

View File

@ -28,15 +28,39 @@ import { openModal } from "./modal";
export const cloudLogger = new Logger("Cloud", "#39b7e0");
export const getCloudUrl = () => new URL(Settings.cloud.url);
const cloudUrlOrigin = () => getCloudUrl().origin;
const getUserId = () => {
const id = UserStore.getCurrentUser()?.id;
if (!id) throw new Error("User not yet logged in");
return id;
};
export async function getAuthorization() {
const secrets = await DataStore.get<Record<string, string>>("Vencord_cloudSecret") ?? {};
return secrets[getCloudUrl().origin];
const origin = cloudUrlOrigin();
// we need to migrate from the old format here
if (secrets[origin]) {
await DataStore.update<Record<string, string>>("Vencord_cloudSecret", secrets => {
secrets ??= {};
// use the current user ID
secrets[`${origin}:${getUserId()}`] = secrets[origin];
delete secrets[origin];
return secrets;
});
// since this doesn't update the original object, we'll early return the existing authorization
return secrets[origin];
}
return secrets[`${origin}:${getUserId()}`];
}
async function setAuthorization(secret: string) {
await DataStore.update<Record<string, string>>("Vencord_cloudSecret", secrets => {
secrets ??= {};
secrets[getCloudUrl().origin] = secret;
secrets[`${cloudUrlOrigin()}:${getUserId()}`] = secret;
return secrets;
});
}
@ -44,7 +68,7 @@ async function setAuthorization(secret: string) {
export async function deauthorizeCloud() {
await DataStore.update<Record<string, string>>("Vencord_cloudSecret", secrets => {
secrets ??= {};
delete secrets[getCloudUrl().origin];
delete secrets[`${cloudUrlOrigin()}:${getUserId()}`];
return secrets;
});
}
@ -117,8 +141,7 @@ export async function authorizeCloud() {
}
export async function getCloudAuth() {
const userId = UserStore.getCurrentUser().id;
const secret = await getAuthorization();
return window.btoa(`${secret}:${userId}`);
return window.btoa(`${secret}:${getUserId()}`);
}

View File

@ -27,8 +27,8 @@ const unconfigurable = ["arguments", "caller", "prototype"];
const handler: ProxyHandler<any> = {};
const GET_KEY = Symbol.for("vencord.lazy.get");
const CACHED_KEY = Symbol.for("vencord.lazy.cached");
const kGET = Symbol.for("vencord.lazy.get");
const kCACHE = Symbol.for("vencord.lazy.cached");
for (const method of [
"apply",
@ -46,11 +46,11 @@ for (const method of [
"setPrototypeOf"
]) {
handler[method] =
(target: any, ...args: any[]) => Reflect[method](target[GET_KEY](), ...args);
(target: any, ...args: any[]) => Reflect[method](target[kGET](), ...args);
}
handler.ownKeys = target => {
const v = target[GET_KEY]();
const v = target[kGET]();
const keys = Reflect.ownKeys(v);
for (const key of unconfigurable) {
if (!keys.includes(key)) keys.push(key);
@ -62,7 +62,7 @@ handler.getOwnPropertyDescriptor = (target, p) => {
if (typeof p === "string" && unconfigurable.includes(p))
return Reflect.getOwnPropertyDescriptor(target, p);
const descriptor = Reflect.getOwnPropertyDescriptor(target[GET_KEY](), p);
const descriptor = Reflect.getOwnPropertyDescriptor(target[kGET](), p);
if (descriptor) Object.defineProperty(target, p, descriptor);
return descriptor;
@ -72,15 +72,22 @@ handler.getOwnPropertyDescriptor = (target, p) => {
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
* On first property access, the lazy is evaluated
* @param factory lazy factory
* @param attempts how many times to try to evaluate the lazy before giving up
* @returns Proxy
*
* Note that the example below exists already as an api, see {@link findByPropsLazy}
* @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah);
*/
export function proxyLazy<T>(factory: () => T): T {
const proxyDummy: { (): void;[CACHED_KEY]?: T;[GET_KEY](): T; } = Object.assign(function () { }, {
[CACHED_KEY]: void 0,
[GET_KEY]: () => proxyDummy[CACHED_KEY] ??= factory(),
export function proxyLazy<T>(factory: () => T, attempts = 5): T {
let tries = 0;
const proxyDummy = Object.assign(function () { }, {
[kCACHE]: void 0 as T | undefined,
[kGET]() {
if (!proxyDummy[kCACHE] && attempts > tries++) {
proxyDummy[kCACHE] = factory();
}
return proxyDummy[kCACHE];
}
});
return new Proxy(proxyDummy, handler) as any;

View File

@ -27,8 +27,12 @@ export async function toggle(isEnabled: boolean) {
if (isEnabled) {
style = document.createElement("style");
style.id = "vencord-custom-css";
document.head.appendChild(style);
VencordNative.quickCss.addChangeListener(css => style.textContent = css);
document.documentElement.appendChild(style);
VencordNative.quickCss.addChangeListener(css => {
style.textContent = css;
// At the time of writing this, changing textContent resets the disabled state
style.disabled = !Settings.useQuickCss;
});
style.textContent = await VencordNative.quickCss.get();
}
} else
@ -39,7 +43,7 @@ async function initThemes() {
if (!themesStyle) {
themesStyle = document.createElement("style");
themesStyle.id = "vencord-themes";
document.head.appendChild(themesStyle);
document.documentElement.appendChild(themesStyle);
}
const { themeLinks } = Settings;

View File

@ -41,10 +41,10 @@ export async function importSettings(data: string) {
throw new Error("Invalid Settings. Is this even a Vencord Settings file?");
}
export async function exportSettings() {
export async function exportSettings({ minify }: { minify?: boolean; } = {}) {
const settings = JSON.parse(VencordNative.settings.get());
const quickCss = await VencordNative.quickCss.get();
return JSON.stringify({ settings, quickCss }, null, 4);
return JSON.stringify({ settings, quickCss }, null, minify ? undefined : 4);
}
export async function downloadSettingsBackup() {
@ -121,8 +121,8 @@ export async function uploadSettingsBackup(showToast = true): Promise<void> {
// Cloud settings
const cloudSettingsLogger = new Logger("Cloud:Settings", "#39b7e0");
export async function putCloudSettings() {
const settings = await exportSettings();
export async function putCloudSettings(manual?: boolean) {
const settings = await exportSettings({ minify: true });
try {
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
@ -149,6 +149,14 @@ export async function putCloudSettings() {
VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4));
cloudSettingsLogger.info("Settings uploaded to cloud successfully");
if (manual) {
showNotification({
title: "Cloud Settings",
body: "Synchronized settings to the cloud!",
noPersist: true,
});
}
} catch (e: any) {
cloudSettingsLogger.error("Failed to sync up", e);
showNotification({