Merge branch 'dev' into modules-proxy-patches
This commit is contained in:
commit
c8097f0f1a
3
.github/ISSUE_TEMPLATE/blank.yml
vendored
3
.github/ISSUE_TEMPLATE/blank.yml
vendored
|
@ -12,7 +12,8 @@ body:
|
||||||
DO NOT USE THIS FORM, unless
|
DO NOT USE THIS FORM, unless
|
||||||
- you are a vencord contributor
|
- you are a vencord contributor
|
||||||
- you were given explicit permission to use this form by a moderator in our support server
|
- you were given explicit permission to use this form by a moderator in our support server
|
||||||
- you are filing a security related report
|
|
||||||
|
DO NOT USE THIS FORM FOR SECURITY RELATED ISSUES. [CREATE A SECURITY ADVISORY INSTEAD.](https://github.com/Vendicated/Vencord/security/advisories/new)
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: content
|
id: content
|
||||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -14,6 +14,8 @@
|
||||||
"typescript.preferences.quoteStyle": "double",
|
"typescript.preferences.quoteStyle": "double",
|
||||||
"javascript.preferences.quoteStyle": "double",
|
"javascript.preferences.quoteStyle": "double",
|
||||||
|
|
||||||
|
"eslint.experimental.useFlatConfig": false,
|
||||||
|
|
||||||
"gitlens.remotes": [
|
"gitlens.remotes": [
|
||||||
{
|
{
|
||||||
"domain": "codeberg.org",
|
"domain": "codeberg.org",
|
||||||
|
|
|
@ -261,8 +261,9 @@ export default function PluginSettings() {
|
||||||
plugins = [];
|
plugins = [];
|
||||||
requiredPlugins = [];
|
requiredPlugins = [];
|
||||||
|
|
||||||
|
const showApi = searchValue.value === "API";
|
||||||
for (const p of sortedPlugins) {
|
for (const p of sortedPlugins) {
|
||||||
if (!p.options && p.name.endsWith("API") && searchValue.value !== "API")
|
if (p.hidden || (!p.options && p.name.endsWith("API") && !showApi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!pluginFilter(p)) continue;
|
if (!pluginFilter(p)) continue;
|
||||||
|
|
9
src/plugins/appleMusic.desktop/README.md
Normal file
9
src/plugins/appleMusic.desktop/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# AppleMusicRichPresence
|
||||||
|
|
||||||
|
This plugin enables Discord rich presence for your Apple Music! (This only works on macOS with the Music app.)
|
||||||
|
|
||||||
|
![Screenshot of the activity in Discord](https://github.com/Vendicated/Vencord/assets/70191398/1f811090-ab5f-4060-a9ee-d0ac44a1d3c0)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
For the customizable activity format strings, you can use several special strings to include track data in activities! `{name}` is replaced with the track name; `{artist}` is replaced with the artist(s)' name(s); and `{album}` is replaced with the album name.
|
253
src/plugins/appleMusic.desktop/index.tsx
Normal file
253
src/plugins/appleMusic.desktop/index.tsx
Normal file
|
@ -0,0 +1,253 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType, PluginNative } from "@utils/types";
|
||||||
|
import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common";
|
||||||
|
|
||||||
|
const Native = VencordNative.pluginHelpers.AppleMusic as PluginNative<typeof import("./native")>;
|
||||||
|
|
||||||
|
interface ActivityAssets {
|
||||||
|
large_image?: string;
|
||||||
|
large_text?: string;
|
||||||
|
small_image?: string;
|
||||||
|
small_text?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ActivityButton {
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Activity {
|
||||||
|
state: string;
|
||||||
|
details?: string;
|
||||||
|
timestamps?: {
|
||||||
|
start?: number;
|
||||||
|
end?: number;
|
||||||
|
};
|
||||||
|
assets?: ActivityAssets;
|
||||||
|
buttons?: Array<string>;
|
||||||
|
name: string;
|
||||||
|
application_id: string;
|
||||||
|
metadata?: {
|
||||||
|
button_urls?: Array<string>;
|
||||||
|
};
|
||||||
|
type: number;
|
||||||
|
flags: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum ActivityType {
|
||||||
|
PLAYING = 0,
|
||||||
|
LISTENING = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum ActivityFlag {
|
||||||
|
INSTANCE = 1 << 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TrackData {
|
||||||
|
name: string;
|
||||||
|
album: string;
|
||||||
|
artist: string;
|
||||||
|
|
||||||
|
appleMusicLink?: string;
|
||||||
|
songLink?: string;
|
||||||
|
|
||||||
|
albumArtwork?: string;
|
||||||
|
artistArtwork?: string;
|
||||||
|
|
||||||
|
playerPosition: number;
|
||||||
|
duration: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum AssetImageType {
|
||||||
|
Album = "Album",
|
||||||
|
Artist = "Artist",
|
||||||
|
}
|
||||||
|
|
||||||
|
const applicationId = "1239490006054207550";
|
||||||
|
|
||||||
|
function setActivity(activity: Activity | null) {
|
||||||
|
FluxDispatcher.dispatch({
|
||||||
|
type: "LOCAL_ACTIVITY_UPDATE",
|
||||||
|
activity,
|
||||||
|
socketId: "AppleMusic",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
activityType: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Which type of activity",
|
||||||
|
options: [
|
||||||
|
{ label: "Playing", value: ActivityType.PLAYING, default: true },
|
||||||
|
{ label: "Listening", value: ActivityType.LISTENING }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
refreshInterval: {
|
||||||
|
type: OptionType.SLIDER,
|
||||||
|
description: "The interval between activity refreshes (seconds)",
|
||||||
|
markers: [1, 2, 2.5, 3, 5, 10, 15],
|
||||||
|
default: 5,
|
||||||
|
restartNeeded: true,
|
||||||
|
},
|
||||||
|
enableTimestamps: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Whether or not to enable timestamps",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
enableButtons: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Whether or not to enable buttons",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
nameString: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Activity name format string",
|
||||||
|
default: "Apple Music"
|
||||||
|
},
|
||||||
|
detailsString: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Activity details format string",
|
||||||
|
default: "{name}"
|
||||||
|
},
|
||||||
|
stateString: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Activity state format string",
|
||||||
|
default: "{artist}"
|
||||||
|
},
|
||||||
|
largeImageType: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Activity assets large image type",
|
||||||
|
options: [
|
||||||
|
{ label: "Album artwork", value: AssetImageType.Album, default: true },
|
||||||
|
{ label: "Artist artwork", value: AssetImageType.Artist }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
largeTextString: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Activity assets large text format string",
|
||||||
|
default: "{album}"
|
||||||
|
},
|
||||||
|
smallImageType: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Activity assets small image type",
|
||||||
|
options: [
|
||||||
|
{ label: "Album artwork", value: AssetImageType.Album },
|
||||||
|
{ label: "Artist artwork", value: AssetImageType.Artist, default: true }
|
||||||
|
],
|
||||||
|
},
|
||||||
|
smallTextString: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Activity assets small text format string",
|
||||||
|
default: "{artist}"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function customFormat(formatStr: string, data: TrackData) {
|
||||||
|
return formatStr
|
||||||
|
.replaceAll("{name}", data.name)
|
||||||
|
.replaceAll("{album}", data.album)
|
||||||
|
.replaceAll("{artist}", data.artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getImageAsset(type: AssetImageType, data: TrackData) {
|
||||||
|
const source = type === AssetImageType.Album
|
||||||
|
? data.albumArtwork
|
||||||
|
: data.artistArtwork;
|
||||||
|
|
||||||
|
if (!source) return undefined;
|
||||||
|
|
||||||
|
return ApplicationAssetUtils.fetchAssetIds(applicationId, [source]).then(ids => ids[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "AppleMusicRichPresence",
|
||||||
|
description: "Discord rich presence for your Apple Music!",
|
||||||
|
authors: [Devs.RyanCaoDev],
|
||||||
|
hidden: !navigator.platform.startsWith("Mac"),
|
||||||
|
|
||||||
|
settingsAboutComponent() {
|
||||||
|
return <>
|
||||||
|
<Forms.FormText>
|
||||||
|
For the customizable activity format strings, you can use several special strings to include track data in activities!{" "}
|
||||||
|
<code>{"{name}"}</code> is replaced with the track name; <code>{"{artist}"}</code> is replaced with the artist(s)' name(s); and <code>{"{album}"}</code> is replaced with the album name.
|
||||||
|
</Forms.FormText>
|
||||||
|
</>;
|
||||||
|
},
|
||||||
|
|
||||||
|
settings,
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this.updatePresence();
|
||||||
|
this.updateInterval = setInterval(() => { this.updatePresence(); }, settings.store.refreshInterval * 1000);
|
||||||
|
},
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
clearInterval(this.updateInterval);
|
||||||
|
FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null });
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePresence() {
|
||||||
|
this.getActivity().then(activity => { setActivity(activity); });
|
||||||
|
},
|
||||||
|
|
||||||
|
async getActivity(): Promise<Activity | null> {
|
||||||
|
const trackData = await Native.fetchTrackData();
|
||||||
|
if (!trackData) return null;
|
||||||
|
|
||||||
|
const [largeImageAsset, smallImageAsset] = await Promise.all([
|
||||||
|
getImageAsset(settings.store.largeImageType, trackData),
|
||||||
|
getImageAsset(settings.store.smallImageType, trackData)
|
||||||
|
]);
|
||||||
|
|
||||||
|
const assets: ActivityAssets = {
|
||||||
|
large_image: largeImageAsset,
|
||||||
|
large_text: customFormat(settings.store.largeTextString, trackData),
|
||||||
|
small_image: smallImageAsset,
|
||||||
|
small_text: customFormat(settings.store.smallTextString, trackData),
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttons: ActivityButton[] = [];
|
||||||
|
|
||||||
|
if (settings.store.enableButtons) {
|
||||||
|
if (trackData.appleMusicLink)
|
||||||
|
buttons.push({
|
||||||
|
label: "Listen on Apple Music",
|
||||||
|
url: trackData.appleMusicLink,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (trackData.songLink)
|
||||||
|
buttons.push({
|
||||||
|
label: "View on SongLink",
|
||||||
|
url: trackData.songLink,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
application_id: applicationId,
|
||||||
|
|
||||||
|
name: customFormat(settings.store.nameString, trackData),
|
||||||
|
details: customFormat(settings.store.detailsString, trackData),
|
||||||
|
state: customFormat(settings.store.stateString, trackData),
|
||||||
|
|
||||||
|
timestamps: (settings.store.enableTimestamps ? {
|
||||||
|
start: Date.now() - (trackData.playerPosition * 1000),
|
||||||
|
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
|
||||||
|
} : undefined),
|
||||||
|
|
||||||
|
assets,
|
||||||
|
|
||||||
|
buttons: buttons.length ? buttons.map(v => v.label) : undefined,
|
||||||
|
metadata: { button_urls: buttons.map(v => v.url) || undefined, },
|
||||||
|
|
||||||
|
type: settings.store.activityType,
|
||||||
|
flags: ActivityFlag.INSTANCE,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
120
src/plugins/appleMusic.desktop/native.ts
Normal file
120
src/plugins/appleMusic.desktop/native.ts
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFile } from "child_process";
|
||||||
|
import { promisify } from "util";
|
||||||
|
|
||||||
|
import type { TrackData } from ".";
|
||||||
|
|
||||||
|
const exec = promisify(execFile);
|
||||||
|
|
||||||
|
// function exec(file: string, args: string[] = []) {
|
||||||
|
// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => {
|
||||||
|
// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] });
|
||||||
|
|
||||||
|
// let stdout: string | null = null;
|
||||||
|
// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; });
|
||||||
|
// let stderr: string | null = null;
|
||||||
|
// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; });
|
||||||
|
|
||||||
|
// process.on("exit", code => { resolve({ code, stdout, stderr }); });
|
||||||
|
// process.on("error", err => reject(err));
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
async function applescript(cmds: string[]) {
|
||||||
|
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
|
||||||
|
return stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeSearchUrl(type: string, query: string) {
|
||||||
|
const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json");
|
||||||
|
url.searchParams.set("types", type);
|
||||||
|
url.searchParams.set("limit", "1");
|
||||||
|
url.searchParams.set("term", query);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestOptions: RequestInit = {
|
||||||
|
headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" },
|
||||||
|
};
|
||||||
|
|
||||||
|
interface RemoteData {
|
||||||
|
appleMusicLink?: string,
|
||||||
|
songLink?: string,
|
||||||
|
albumArtwork?: string,
|
||||||
|
artistArtwork?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
|
||||||
|
|
||||||
|
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
||||||
|
if (id === cachedRemoteData?.id) {
|
||||||
|
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
||||||
|
if ("failures" in cachedRemoteData && cachedRemoteData.failures >= 5) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [songData, artistData] = await Promise.all([
|
||||||
|
fetch(makeSearchUrl("songs", artist + " " + album + " " + name), requestOptions).then(r => r.json()),
|
||||||
|
fetch(makeSearchUrl("artists", artist.split(/ *[,&] */)[0]), requestOptions).then(r => r.json())
|
||||||
|
]);
|
||||||
|
|
||||||
|
const appleMusicLink = songData?.songs?.data[0]?.attributes.url;
|
||||||
|
const songLink = songData?.songs?.data[0]?.id ? `https://song.link/i/${songData?.songs?.data[0]?.id}` : undefined;
|
||||||
|
|
||||||
|
const albumArtwork = songData?.songs?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
||||||
|
const artistArtwork = artistData?.artists?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
||||||
|
|
||||||
|
cachedRemoteData = {
|
||||||
|
id,
|
||||||
|
data: { appleMusicLink, songLink, albumArtwork, artistArtwork }
|
||||||
|
};
|
||||||
|
return cachedRemoteData.data;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("[AppleMusicRichPresence] Failed to fetch remote data:", e);
|
||||||
|
cachedRemoteData = {
|
||||||
|
id,
|
||||||
|
failures: (id === cachedRemoteData?.id && "failures" in cachedRemoteData ? cachedRemoteData.failures : 0) + 1
|
||||||
|
};
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchTrackData(): Promise<TrackData | null> {
|
||||||
|
try {
|
||||||
|
await exec("pgrep", ["^Music$"]);
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const playerState = await applescript(['tell application "Music"', "get player state", "end tell"])
|
||||||
|
.then(out => out.trim());
|
||||||
|
if (playerState !== "playing") return null;
|
||||||
|
|
||||||
|
const playerPosition = await applescript(['tell application "Music"', "get player position", "end tell"])
|
||||||
|
.then(text => Number.parseFloat(text.trim()));
|
||||||
|
|
||||||
|
const stdout = await applescript([
|
||||||
|
'set output to ""',
|
||||||
|
'tell application "Music"',
|
||||||
|
"set t_id to database id of current track",
|
||||||
|
"set t_name to name of current track",
|
||||||
|
"set t_album to album of current track",
|
||||||
|
"set t_artist to artist of current track",
|
||||||
|
"set t_duration to duration of current track",
|
||||||
|
'set output to "" & t_id & "\\n" & t_name & "\\n" & t_album & "\\n" & t_artist & "\\n" & t_duration',
|
||||||
|
"end tell",
|
||||||
|
"return output"
|
||||||
|
]);
|
||||||
|
|
||||||
|
const [id, name, album, artist, durationStr] = stdout.split("\n").filter(k => !!k);
|
||||||
|
const duration = Number.parseFloat(durationStr);
|
||||||
|
|
||||||
|
const remoteData = await fetchRemoteData({ id, name, artist, album });
|
||||||
|
|
||||||
|
return { name, album, artist, playerPosition, duration, ...remoteData };
|
||||||
|
}
|
5
src/plugins/copyEmojiMarkdown/README.md
Normal file
5
src/plugins/copyEmojiMarkdown/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# CopyEmojiMarkdown
|
||||||
|
|
||||||
|
Allows you to copy emojis as formatted string. Custom emojis will be copied as `<:trolley:1024751352028602449>`, default emojis as `🛒`
|
||||||
|
|
||||||
|
![](https://github.com/Vendicated/Vencord/assets/45497981/417f345a-7031-4fe7-8e42-e238870cd547)
|
75
src/plugins/copyEmojiMarkdown/index.tsx
Normal file
75
src/plugins/copyEmojiMarkdown/index.tsx
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { copyWithToast } from "@utils/misc";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { Menu } from "@webpack/common";
|
||||||
|
|
||||||
|
const { convertNameToSurrogate } = findByPropsLazy("convertNameToSurrogate");
|
||||||
|
|
||||||
|
interface Emoji {
|
||||||
|
type: string;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Target {
|
||||||
|
dataset: Emoji;
|
||||||
|
firstChild: HTMLImageElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEmojiMarkdown(target: Target, copyUnicode: boolean): string {
|
||||||
|
const { id: emojiId, name: emojiName } = target.dataset;
|
||||||
|
|
||||||
|
if (!emojiId) {
|
||||||
|
return copyUnicode
|
||||||
|
? convertNameToSurrogate(emojiName)
|
||||||
|
: `:${emojiName}:`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const extension = target?.firstChild.src.match(
|
||||||
|
/https:\/\/cdn\.discordapp\.com\/emojis\/\d+\.(\w+)/
|
||||||
|
)?.[1];
|
||||||
|
|
||||||
|
return `<${extension === "gif" ? "a" : ""}:${emojiName.replace(/~\d+$/, "")}:${emojiId}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
copyUnicode: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Copy the raw unicode character instead of :name: for default emojis (👽)",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "CopyEmojiMarkdown",
|
||||||
|
description: "Allows you to copy emojis as formatted string (<:blobcatcozy:1026533070955872337>)",
|
||||||
|
authors: [Devs.HappyEnderman, Devs.Vishnya],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
contextMenus: {
|
||||||
|
"expression-picker"(children, { target }: { target: Target }) {
|
||||||
|
if (target.dataset.type !== "emoji") return;
|
||||||
|
|
||||||
|
children.push(
|
||||||
|
<Menu.MenuItem
|
||||||
|
id="vc-copy-emoji-markdown"
|
||||||
|
label="Copy Emoji Markdown"
|
||||||
|
action={() => {
|
||||||
|
copyWithToast(
|
||||||
|
getEmojiMarkdown(target, settings.store.copyUnicode),
|
||||||
|
"Success! Copied emoji markdown."
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
3
src/plugins/experiments/hideBugReport.css
Normal file
3
src/plugins/experiments/hideBugReport.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#staff-help-popout-staff-help-bug-reporter {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -16,31 +16,22 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { disableStyle, enableStyle } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Forms, React, UserStore } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
|
||||||
|
import hideBugReport from "./hideBugReport.css?managed";
|
||||||
|
|
||||||
const KbdStyles = findByPropsLazy("key", "removeBuildOverride");
|
const KbdStyles = findByPropsLazy("key", "removeBuildOverride");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
|
||||||
enableIsStaff: {
|
|
||||||
description: "Enable isStaff",
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
default: false,
|
|
||||||
restartNeeded: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "Experiments",
|
name: "Experiments",
|
||||||
description: "Enable Access to Experiments in Discord!",
|
description: "Enable Access to Experiments & other dev-only features in Discord!",
|
||||||
authors: [
|
authors: [
|
||||||
Devs.Megu,
|
Devs.Megu,
|
||||||
Devs.Ven,
|
Devs.Ven,
|
||||||
|
@ -48,7 +39,6 @@ export default definePlugin({
|
||||||
Devs.BanTheNons,
|
Devs.BanTheNons,
|
||||||
Devs.Nuckyz
|
Devs.Nuckyz
|
||||||
],
|
],
|
||||||
settings,
|
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
|
@ -65,37 +55,25 @@ export default definePlugin({
|
||||||
replace: "$1=!0;"
|
replace: "$1=!0;"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: '"isStaff",',
|
|
||||||
predicate: () => settings.store.enableIsStaff,
|
|
||||||
replacement: [
|
|
||||||
{
|
|
||||||
match: /(?<=>)(\i)\.hasFlag\((\i\.\i)\.STAFF\)(?=})/,
|
|
||||||
replace: (_, user, flags) => `$self.isStaff(${user},${flags})`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
match: /hasFreePremium\(\){return this.isStaff\(\)\s*?\|\|/,
|
|
||||||
replace: "hasFreePremium(){return ",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: 'H1,title:"Experiments"',
|
find: 'H1,title:"Experiments"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: 'title:"Experiments",children:[',
|
match: 'title:"Experiments",children:[',
|
||||||
replace: "$&$self.WarningCard(),"
|
replace: "$&$self.WarningCard(),"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// change top right chat toolbar button from the help one to the dev one
|
||||||
|
{
|
||||||
|
find: "toolbar:function",
|
||||||
|
replacement: {
|
||||||
|
match: /\i\.isStaff\(\)/,
|
||||||
|
replace: "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
isStaff(user: User, flags: any) {
|
start: () => enableStyle(hideBugReport),
|
||||||
try {
|
stop: () => disableStyle(hideBugReport),
|
||||||
return UserStore.getCurrentUser()?.id === user.id || user.hasFlag(flags.STAFF);
|
|
||||||
} catch (err) {
|
|
||||||
new Logger("Experiments").error(err);
|
|
||||||
return user.hasFlag(flags.STAFF);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
settingsAboutComponent: () => {
|
settingsAboutComponent: () => {
|
||||||
const isMacOS = navigator.platform.includes("Mac");
|
const isMacOS = navigator.platform.includes("Mac");
|
||||||
|
@ -105,14 +83,10 @@ export default definePlugin({
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
||||||
<Forms.FormText variant="text-md/normal">
|
<Forms.FormText variant="text-md/normal">
|
||||||
You can enable client DevTools{" "}
|
You can open Discord's DevTools via {" "}
|
||||||
<kbd className={KbdStyles.key}>{modKey}</kbd> +{" "}
|
<kbd className={KbdStyles.key}>{modKey}</kbd> +{" "}
|
||||||
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
|
<kbd className={KbdStyles.key}>{altKey}</kbd> +{" "}
|
||||||
<kbd className={KbdStyles.key}>O</kbd>{" "}
|
<kbd className={KbdStyles.key}>O</kbd>{" "}
|
||||||
after enabling <code>isStaff</code> below
|
|
||||||
</Forms.FormText>
|
|
||||||
<Forms.FormText>
|
|
||||||
and then toggling <code>Enable DevTools</code> in the <code>Developer Options</code> tab in settings.
|
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
@ -128,6 +102,12 @@ export default definePlugin({
|
||||||
|
|
||||||
<Forms.FormText className={Margins.top8}>
|
<Forms.FormText className={Margins.top8}>
|
||||||
Only use experiments if you know what you're doing. Vencord is not responsible for any damage caused by enabling experiments.
|
Only use experiments if you know what you're doing. Vencord is not responsible for any damage caused by enabling experiments.
|
||||||
|
|
||||||
|
If you don't know what an experiment does, ignore it. Do not ask us what experiments do either, we probably don't know.
|
||||||
|
</Forms.FormText>
|
||||||
|
|
||||||
|
<Forms.FormText className={Margins.top8}>
|
||||||
|
No, you cannot use server-side features like checking the "Send to Client" box.
|
||||||
</Forms.FormText>
|
</Forms.FormText>
|
||||||
</ErrorCard>
|
</ErrorCard>
|
||||||
), { noop: true })
|
), { noop: true })
|
||||||
|
|
|
@ -20,10 +20,10 @@ const FriendRow = findExportedComponentLazy("FriendRow");
|
||||||
|
|
||||||
const cl = classNameFactory("vc-gp-");
|
const cl = classNameFactory("vc-gp-");
|
||||||
|
|
||||||
export function openGuildProfileModal(guild: Guild) {
|
export function openGuildInfoModal(guild: Guild) {
|
||||||
openModal(props =>
|
openModal(props =>
|
||||||
<ModalRoot {...props} size={ModalSize.MEDIUM}>
|
<ModalRoot {...props} size={ModalSize.MEDIUM}>
|
||||||
<GuildProfileModal guild={guild} />
|
<GuildInfoModal guild={guild} />
|
||||||
</ModalRoot>
|
</ModalRoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ function renderTimestamp(timestamp: number) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GuildProfileModal({ guild }: GuildProps) {
|
function GuildInfoModal({ guild }: GuildProps) {
|
||||||
const [friendCount, setFriendCount] = useState<number>();
|
const [friendCount, setFriendCount] = useState<number>();
|
||||||
const [blockedCount, setBlockedCount] = useState<number>();
|
const [blockedCount, setBlockedCount] = useState<number>();
|
||||||
|
|
7
src/plugins/serverInfo/README.md
Normal file
7
src/plugins/serverInfo/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# ServerInfo
|
||||||
|
|
||||||
|
Allows you to view info about servers and see friends and blocked users
|
||||||
|
|
||||||
|
![](https://github.com/Vendicated/Vencord/assets/45497981/a49783b5-e8fc-41d8-968f-58600e9f6580)
|
||||||
|
![](https://github.com/Vendicated/Vencord/assets/45497981/5efc158a-e671-4196-a15a-77edf79a2630)
|
||||||
|
![Available as "Server Profile" option in the server context menu](https://github.com/Vendicated/Vencord/assets/45497981/f43be943-6dc4-4232-9709-fbeb382d8e54)
|
|
@ -5,30 +5,32 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
|
import { migratePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Menu } from "@webpack/common";
|
import { Menu } from "@webpack/common";
|
||||||
import { Guild } from "discord-types/general";
|
import { Guild } from "discord-types/general";
|
||||||
|
|
||||||
import { openGuildProfileModal } from "./GuildProfileModal";
|
import { openGuildInfoModal } from "./GuildInfoModal";
|
||||||
|
|
||||||
const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; }) => {
|
const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild; }) => {
|
||||||
const group = findGroupChildrenByChildId("privacy", children);
|
const group = findGroupChildrenByChildId("privacy", children);
|
||||||
|
|
||||||
group?.push(
|
group?.push(
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vc-server-profile"
|
id="vc-server-info"
|
||||||
label="Server Info"
|
label="Server Info"
|
||||||
action={() => openGuildProfileModal(guild)}
|
action={() => openGuildInfoModal(guild)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
migratePluginSettings("ServerInfo", "ServerProfile"); // what was I thinking with this name lmao
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ServerProfile",
|
name: "ServerInfo",
|
||||||
description: "Allows you to view info about a server by right clicking it in the server list",
|
description: "Allows you to view info about a server",
|
||||||
authors: [Devs.Ven, Devs.Nuckyz],
|
authors: [Devs.Ven, Devs.Nuckyz],
|
||||||
tags: ["guild", "info"],
|
tags: ["guild", "info", "ServerProfile"],
|
||||||
contextMenus: {
|
contextMenus: {
|
||||||
"guild-context": Patch,
|
"guild-context": Patch,
|
||||||
"guild-header-popout": Patch
|
"guild-header-popout": Patch
|
|
@ -1,7 +0,0 @@
|
||||||
# ServerProfile
|
|
||||||
|
|
||||||
Allows you to view info about servers and see friends and blocked users
|
|
||||||
|
|
||||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/a49783b5-e8fc-41d8-968f-58600e9f6580)
|
|
||||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/5efc158a-e671-4196-a15a-77edf79a2630)
|
|
||||||
![image](https://github.com/Vendicated/Vencord/assets/45497981/f43be943-6dc4-4232-9709-fbeb382d8e54)
|
|
|
@ -441,6 +441,14 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "Elvyra",
|
name: "Elvyra",
|
||||||
id: 708275751816003615n,
|
id: 708275751816003615n,
|
||||||
},
|
},
|
||||||
|
HappyEnderman: {
|
||||||
|
name: "Happy enderman",
|
||||||
|
id: 1083437693347827764n
|
||||||
|
},
|
||||||
|
Vishnya: {
|
||||||
|
name: "Vishnya",
|
||||||
|
id: 282541644484575233n
|
||||||
|
},
|
||||||
Inbestigator: {
|
Inbestigator: {
|
||||||
name: "Inbestigator",
|
name: "Inbestigator",
|
||||||
id: 761777382041714690n
|
id: 761777382041714690n
|
||||||
|
|
|
@ -85,6 +85,10 @@ export interface PluginDef {
|
||||||
* Whether this plugin is required and forcefully enabled
|
* Whether this plugin is required and forcefully enabled
|
||||||
*/
|
*/
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
/**
|
||||||
|
* Whether this plugin should be hidden from the user
|
||||||
|
*/
|
||||||
|
hidden?: boolean;
|
||||||
/**
|
/**
|
||||||
* Whether this plugin should be enabled by default, but can be disabled
|
* Whether this plugin should be enabled by default, but can be disabled
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue