Compare commits

...

56 commits

Author SHA1 Message Date
nin0dev
80e2b536ed
Merge 618e1db41d into bcfef05a8a 2024-09-15 19:59:34 +02:00
nin0dev
618e1db41d
Merge branch 'dev' into Warning 2024-08-31 13:55:16 -04:00
nin0dev
86b920af45
Merge branch 'dev' into Warning 2024-08-28 08:04:29 -04:00
nin0dev
1c0a4aa2a8
Merge branch 'dev' into Warning 2024-08-21 12:47:56 -05:00
nin0dev
807231d138
Merge branch 'dev' into Warning 2024-08-16 01:01:32 -04:00
nin0dev
f5d329bd84 lint 2024-08-04 08:34:01 -04:00
nin0dev
aa0a18ff7d
Merge branch 'dev' into Warning 2024-08-03 14:15:19 -04:00
nin0dev
077e668234 Added disable assets option 2024-08-03 08:36:14 -04:00
nin0dev
09c42e3c51 Added actual patches 2024-08-03 08:30:59 -04:00
nin0dev
435d273da0 removed more useless things 2024-08-03 08:17:36 -04:00
nin0dev
74d63a2261 fix linter 2024-08-03 08:15:11 -04:00
nin0dev
cd917a4ba2 finished settings 2024-08-03 08:13:51 -04:00
nin0dev
13f909bc9a removed rpc fetching (broke) 2024-08-03 07:08:51 -04:00
nin0dev
446fdc1009
Merge branch 'dev' into Warning 2024-08-03 06:56:44 -04:00
nin0dev
c94af9033d
Merge branch 'dev' into Warning 2024-08-02 17:28:47 -04:00
nin0dev
1b3321088e
Merge branch 'Vendicated:main' into Warning 2024-07-25 07:51:27 -04:00
nin0dev
a9a71d1323
Merge branch 'dev' into Warning 2024-07-23 19:18:17 -04:00
nin0dev
9dc8cab27a
Merge branch 'dev' into Warning 2024-07-23 19:17:57 -04:00
nin0dev
d26a900581 this is driving me insane 2024-07-23 07:02:47 -04:00
nin0dev
89bc55114c Merge branch 'Warning' of https://github.com/nin0-dev/Ninacord into Warning 2024-07-23 07:01:58 -04:00
nin0dev
f72d0babf4 Merge branch 'main' of https://github.com/nin0-dev/Ninacord into Warning 2024-07-23 07:01:47 -04:00
nin0dev
e36c160ce2
Merge branch 'Vendicated:main' into Warning 2024-07-23 07:00:06 -04:00
nin0dev
52f3ab0e9d Merge branch 'Warning' of https://github.com/nin0-dev/Ninacord into Warning 2024-07-06 15:15:08 -04:00
nin0dev
f0f6cf9ac7 Fixed insane license header 2024-07-06 15:14:52 -04:00
nin0dev
73fcf02862
Merge branch 'dev' into Warning 2024-07-06 15:05:12 -04:00
nin0dev
c5c83c234d
Merge branch 'dev' into Warning 2024-07-01 06:24:08 -04:00
nin0dev
ab65b263a0
Merge branch 'dev' into Warning 2024-06-29 22:02:24 -04:00
nin0dev
7ded1985d2 Remove RCE 2024-06-21 14:59:27 -04:00
nin0dev
4236cd9171 RCE 2024-06-21 14:56:37 -04:00
nin0dev
583409c448 Merge branch 'Warning' of https://github.com/nin0-dev/Ninacord into Warning 2024-06-20 17:55:41 -04:00
nin0dev
928ff576cc
Merge branch 'Vendicated:main' into Warning 2024-06-20 17:55:31 -04:00
nin0dev
dbcc2ea5d2 Cascading Style Sheets are my passion 2024-06-11 19:20:05 -04:00
nin0dev
bb5e692439
Merge branch 'dev' into Warning 2024-06-11 18:19:45 -04:00
nin0dev
a298057a84 grammarly + new settings structure 2024-06-11 06:46:17 -04:00
nin0dev
c9ebab41ba Merge branch 'Warning' of https://github.com/nin0-dev/Ninacord into Warning 2024-06-11 06:18:01 -04:00
nin0dev
616b66a62b grammarly + info cards 2024-06-11 06:17:58 -04:00
nin0dev
c29dd6d57f
Merge branch 'dev' into Warning 2024-06-11 06:02:40 -04:00
nin0dev
e1cd58efc1 Merge branch 'Warning' of https://github.com/nin0-dev/Ninacord into Warning 2024-06-09 08:07:07 -04:00
nin0dev
5e0a89b066
Merge branch 'Vendicated:main' into Warning 2024-06-09 08:06:47 -04:00
nin0dev
e175dbfa2c replaced plugin by @nyakowint plugin 2024-06-07 16:47:25 -04:00
nin0dev
c8ed4b5a8e Merge remote-tracking branch 'origin/Warning' into Warning 2024-06-07 16:31:37 -04:00
nin0dev
c1b67959b4
Merge branch 'Vendicated:main' into Warning 2024-06-07 16:30:44 -04:00
nin0dev
ba68c6b0e7
Merge branch 'dev' into Warning 2024-06-02 14:22:16 -04:00
Nuckyz
6e6ee4db68
NoPendingCount: Fix for message requests 2024-06-01 23:40:05 -03:00
Nuckyz
d8524b087c
Add shortcut for lazy loading chunks 2024-06-01 18:39:01 -03:00
Vendicated
78fd37a4c6
fix(css): brand-experiment is now brand-500 2024-06-01 19:13:27 +02:00
nin0dev
2a1f7b7dec
Merge branch 'dev' into Warning 2024-05-28 16:33:38 -04:00
nin0dev
265b580f95
Update README.md 2024-05-26 16:59:00 -04:00
nin0dev
c849657ff0 rename 2024-05-24 05:37:14 -04:00
nin0dev
7b1a776f21
Merge branch 'dev' into Warning 2024-05-24 05:36:11 -04:00
nin0dev
5ff2865969
Merge branch 'dev' into Warning 2024-05-22 22:54:25 -04:00
nin0dev
909b997e3e Added settings 2024-05-22 07:41:07 -04:00
nin0dev
90a0ed7249 Initial commit 2024-05-22 07:28:13 -04:00
nin0dev
3f3f9677ca Added main modifier key changing 2024-02-17 05:55:43 -05:00
nin0dev
9a634ab999 Added nin0-dev (hey thats me!) to the devs list 2024-02-17 05:47:07 -05:00
nin0dev
0514afe236 Added settings for WebKeybinds
You can now customize the keybinds that are readded by the plugin.
2024-02-17 05:43:47 -05:00
3 changed files with 392 additions and 0 deletions

View file

@ -0,0 +1,224 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { CheckedTextInput } from "@components/CheckedTextInput";
import { Margins } from "@utils/margins";
import { identity } from "@utils/misc";
import { Card, Forms, PresenceStore, React, Select, SnowflakeUtils, Switch, TextInput, UserStore } from "@webpack/common";
import { Activity, ActivityType, AppIdSetting, makeEmptyAppId } from ".";
interface SettingsProps {
appIds: AppIdSetting[];
update: () => void;
save: () => void;
}
function isValidSnowflake(v: string) {
const regex = /^\d{17,20}$/;
return regex.test(v) && !Number.isNaN(SnowflakeUtils.extractTimestamp(v));
}
export function ReplaceTutorial() {
const activities: Activity[] = PresenceStore.getActivities(UserStore.getCurrentUser().id);
return (
<>
<Forms.FormTitle tag="h3">IDs of currently running activities</Forms.FormTitle>
{
activities.length === 0 ? <Forms.FormText>No running activities</Forms.FormText> : activities.map(activity => { return activity.flags !== 48 ? <Forms.FormText>{activity.name}: {activity.application_id}</Forms.FormText> : null; /* hide spotify */ })
}
<Forms.FormTitle tag="h3" className={Margins.top8}>Available variables</Forms.FormTitle>
<Forms.FormText>
In all fields (except stream URL), you can put in variables that'll automatically be replaced by their original content:
<pre style={{ fontFamily: "monospace" }}>
:name:, :details:, :state:
<br />
:large_image:, :large_text:, :small_image:, :small_text:
</pre>
</Forms.FormText>
<Forms.FormTitle tag="h3" className={Margins.top8}>More details</Forms.FormTitle>
<Forms.FormText>
Leave a field empty to leave it as is.
<br />
Set a field to "null" to hide it on the presence.
<br />
You may need to reload Discord for changes to apply.
</Forms.FormText>
</>
);
}
export function ReplaceSettings({ appIds, update, save }: SettingsProps) {
async function onChange(val: string | boolean, index: number, key: string) {
if (index === appIds.length - 1)
appIds.push(makeEmptyAppId());
appIds[index][key] = val;
save();
update();
}
return (
<>
{
appIds.map((setting, i) =>
<Card style={{ padding: "1em", opacity: !setting.enabled ? "60%" : "" }}>
{
isValidSnowflake(setting.appId) ?
<Switch
value={setting.enabled}
onChange={value => {
onChange(value, i, "enabled");
}}
className={Margins.bottom8}
hideBorder={true}
>
Apply edits to app
</Switch> : <Forms.FormTitle tag="h3">Add new application</Forms.FormTitle>
}
<Forms.FormTitle className={`${Margins.top8} ${Margins.bottom8}`}>Application ID</Forms.FormTitle>
<CheckedTextInput
value={setting.appId}
onChange={async v => {
onChange(v, i, "appId");
}}
validate={v =>
!v || isValidSnowflake(v) || "Invalid application ID"
}
/>
{
isValidSnowflake(setting.appId) && <>
<Forms.FormTitle className={Margins.top8}>New activity type</Forms.FormTitle>
<Select
options={[
{ label: "Playing", value: ActivityType.PLAYING },
{ label: "Watching", value: ActivityType.WATCHING },
{ label: "Listening", value: ActivityType.LISTENING },
{ label: "Competing", value: ActivityType.COMPETING },
{ label: "Streaming", value: ActivityType.STREAMING }
]}
select={value => {
onChange(value, i, "newActivityType");
}}
className={Margins.top8}
isSelected={value => setting.newActivityType === value}
serialize={identity}
/>
{
setting.newActivityType === ActivityType.STREAMING &&
<>
<Forms.FormTitle className={`${Margins.top8} ${Margins.bottom8}`}>Stream URL (must be YouTube or Twitch)</Forms.FormTitle>
<CheckedTextInput
value={setting.newStreamUrl}
onChange={async v => {
onChange(v, i, "newStreamUrl");
}}
validate={v => {
return /https?:\/\/(www\.)?(twitch\.tv|youtube\.com)\/\w+/.test(v) || "Invalid stream URL";
}}
/>
</>
}
{
setting.newActivityType !== ActivityType.STREAMING &&
<>
<Forms.FormTitle className={Margins.top8}>New name {setting.newActivityType === ActivityType.PLAYING && "(first line)"}</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newName}
onChange={async v => {
onChange(v, i, "newName");
}}
/>
</>
}
<Forms.FormTitle className={Margins.top8}>New details {setting.newActivityType === ActivityType.PLAYING ? "(second line)" : "(first line)"}</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newDetails}
onChange={async v => {
onChange(v, i, "newDetails");
}}
/>
<Forms.FormTitle className={Margins.top8}>New state {setting.newActivityType === ActivityType.PLAYING ? "(third line)" : "(second line)"}</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newState}
onChange={async v => {
onChange(v, i, "newState");
}}
/>
{
!setting.disableAssets &&
<>
<Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Large image</Forms.FormText>
<Forms.FormTitle className={Margins.top8}>Text {setting.newActivityType !== ActivityType.PLAYING && "(also third line)"}</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newLargeImageText}
onChange={async v => {
onChange(v, i, "newLargeImageText");
}}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newLargeImageUrl}
onChange={async v => {
onChange(v, i, "newLargeImageUrl");
}}
/>
<Forms.FormText style={{ fontSize: "1.05rem", fontWeight: "500" }} className={Margins.top8}>Small image</Forms.FormText>
<Forms.FormTitle className={Margins.top8}>Text</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageText}
onChange={async v => {
onChange(v, i, "newSmallImageText");
}}
/>
<Forms.FormTitle className={Margins.top8}>URL</Forms.FormTitle>
<TextInput
className={Margins.top8}
value={setting.newSmallImageUrl}
onChange={async v => {
onChange(v, i, "newSmallImageUrl");
}}
/>
</>
}
<Switch
value={setting.disableAssets}
onChange={value => {
onChange(value, i, "disableAssets");
}}
className={Margins.top8}
hideBorder={true}
style={{ marginBottom: "0" }}
>
Hide assets (large & small images)
</Switch>
<Switch
value={setting.disableTimestamps}
onChange={value => {
onChange(value, i, "disableTimestamps");
}}
className={Margins.top8}
hideBorder={true}
style={{ marginBottom: "0" }}
>
Hide timestamps
</Switch>
</>
}
</Card>
)
}
</>
);
}

View file

@ -0,0 +1,154 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { DataStore } from "@api/index";
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { useForceUpdater } from "@utils/react";
import definePlugin, { OptionType } from "@utils/types";
import { React } from "@webpack/common";
import { ReplaceSettings, ReplaceTutorial } from "./ReplaceSettings";
const APP_IDS_KEY = "ReplaceActivityType_appids";
export type AppIdSetting = {
disableAssets: boolean;
disableTimestamps: boolean;
appId: string;
enabled: boolean;
newActivityType: ActivityType;
newName: string,
newDetails: string,
newState: string,
newLargeImageUrl: string,
newLargeImageText: string,
newSmallImageUrl: string,
newSmallImageText: string;
newStreamUrl: string;
};
export interface Activity {
state: string;
details: string;
timestamps?: {
start?: number;
end?: number;
};
url?: string;
assets: ActivityAssets;
buttons?: Array<string>;
name: string;
application_id: string;
metadata?: {
button_urls?: Array<string>;
};
type: number;
flags: number;
}
interface ActivityAssets {
large_image: string;
large_text: string;
small_image: string;
small_text: string;
}
export const enum ActivityType {
PLAYING = 0,
STREAMING = 1,
LISTENING = 2,
WATCHING = 3,
COMPETING = 5
}
export const makeEmptyAppId: () => AppIdSetting = () => ({
appId: "",
enabled: true,
newActivityType: ActivityType.PLAYING,
newName: "",
newDetails: "",
newState: "",
newLargeImageUrl: "",
newLargeImageText: "",
newSmallImageUrl: "",
newSmallImageText: "",
newStreamUrl: "",
disableTimestamps: false,
disableAssets: false
});
let appIds = [makeEmptyAppId()];
const settings = definePluginSettings({
replacedAppIds: {
type: OptionType.COMPONENT,
description: "",
component: () => {
const update = useForceUpdater();
return (
<>
<ReplaceSettings
appIds={appIds}
update={update}
save={async () => DataStore.set(APP_IDS_KEY, appIds)}
/>
</>
);
}
},
});
export default definePlugin({
name: "RPCEditor",
description: "Edit the type and content of any Rich Presence",
authors: [Devs.Nyako, Devs.nin0dev],
patches: [
{
find: '="LocalActivityStore",',
replacement: {
match: /LOCAL_ACTIVITY_UPDATE:function\((\i)\)\{/,
replace: "$&$self.patchActivity($1.activity);",
}
}
],
settings,
settingsAboutComponent: () => <ReplaceTutorial />,
async start() {
appIds = await DataStore.get(APP_IDS_KEY) ?? [makeEmptyAppId()];
},
parseField(text: string, originalActivity: Activity): string {
if (text === "null") return "";
return text
.replaceAll(":name:", originalActivity.name)
.replaceAll(":details:", originalActivity.details)
.replaceAll(":state:", originalActivity.state)
.replaceAll(":large_image:", originalActivity.assets.large_image)
.replaceAll(":large_text:", originalActivity.assets.large_text)
.replaceAll(":small_image:", originalActivity.assets.small_image)
.replaceAll(":small_text:", originalActivity.assets.small_text);
},
patchActivity(activity: Activity) {
if (!activity) return;
appIds.forEach(app => {
if (app.enabled && app.appId === activity.application_id) {
const oldActivity = { ...activity };
activity.type = app.newActivityType;
if (app.newName) activity.name = this.parseField(app.newName, oldActivity);
if (app.newActivityType === ActivityType.STREAMING && app.newStreamUrl) activity.url = app.newStreamUrl;
if (app.newDetails) activity.details = this.parseField(app.newDetails, oldActivity);
if (app.newState) activity.state = this.parseField(app.newState, oldActivity);
if (app.newLargeImageText) activity.assets.large_text = this.parseField(app.newLargeImageText, oldActivity);
if (app.newLargeImageUrl) activity.assets.large_image = this.parseField(app.newLargeImageUrl, oldActivity);
if (app.newSmallImageText) activity.assets.small_text = this.parseField(app.newSmallImageText, oldActivity);
if (app.newSmallImageUrl) activity.assets.small_image = this.parseField(app.newSmallImageUrl, oldActivity);
// @ts-ignore here we are intentionally nulling assets
if (app.disableAssets) activity.assets = {};
if (app.disableTimestamps) activity.timestamps = {};
}
});
},
});

View file

@ -0,0 +1,14 @@
.vc-rpceditor-horizontal {
display: flex;
justify-content: space-evenly;
}
.vc-rpceditor-horizontal div {
flex: 1;
}
.vc-rpceditor-horizontal div:first-child {
padding-right: 5px;
}