:blobloblobloblobcatcozy:

This commit is contained in:
sadan 2025-01-26 22:59:00 -05:00
parent 1693273f8b
commit e0040c44fd
No known key found for this signature in database

View file

@ -5,14 +5,14 @@
*/ */
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { copyWithToast } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByCodeLazy } from "@webpack"; import { findByCodeLazy } from "@webpack";
import { Clipboard, Toasts } from "@webpack/common";
import { User } from "discord-types/general"; import { User } from "discord-types/general";
interface MakeContextMenuProps { interface MakeContextMenuProps {
user: User, user: User,
activity: any activity: any;
} }
// This is an API call if the result is not cached // This is an API call if the result is not cached
@ -27,7 +27,7 @@ export default definePlugin({
{ {
find: "?\"PRESS_WATCH_ON_CRUNCHYROLL_BUTTON\"", find: "?\"PRESS_WATCH_ON_CRUNCHYROLL_BUTTON\"",
replacement: { replacement: {
match: /(?=onClick)(?=.*index:(\i))/, match: /(?=onClick)(?=.{0,200}index:(\i))/,
replace: "onContextMenu: $self.makeContextMenu(arguments[0], $1)," replace: "onContextMenu: $self.makeContextMenu(arguments[0], $1),"
} }
} }
@ -35,31 +35,12 @@ export default definePlugin({
makeContextMenu(props: MakeContextMenuProps, index: number) { makeContextMenu(props: MakeContextMenuProps, index: number) {
return async () => { return async () => {
try { const { button_urls } = await getMetadataFromApi(props.activity, props.user.id);
const { button_urls } = await getMetadataFromApi(props.activity, props.user.id); if (!button_urls[index]) {
if (!button_urls[index]) { console.error("button_urls does not contain index");
throw new Error("button_urls does not contain index"); return;
}
Clipboard.copy(button_urls[index]);
Toasts.show({
id: Toasts.genId(),
message: "Copied URL",
type: Toasts.Type.SUCCESS,
options: {
position: Toasts.Position.TOP
}
});
} catch (e) {
console.error(e);
Toasts.show({
id: Toasts.genId(),
message: "Error copying URL, check console for more info",
type: Toasts.Type.FAILURE,
options: {
position: Toasts.Position.TOP
}
});
} }
copyWithToast(button_urls[index]);
}; };
} }
}); });