Add nitro bypass (#4)
parent
a7ccbcfca4
commit
c3ff092162
@ -0,0 +1 @@
|
||||
{}
|
@ -1,17 +0,0 @@
|
||||
type Listener = (message, channel, event) => void;
|
||||
|
||||
const listeners = new Set<Listener>();
|
||||
|
||||
export function _handleClick(message, channel, event) {
|
||||
for (const listener of listeners) {
|
||||
listener(message, channel, event);
|
||||
}
|
||||
}
|
||||
|
||||
export function addListener(listener: Listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
export function removeListener(listener: Listener) {
|
||||
return listeners.delete(listener);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
import type { Message, Channel } from 'discord-types/general';
|
||||
import Logger from '../utils/logger';
|
||||
|
||||
const MessageEventsLogger = new Logger("MessageEvents", "#e5c890");
|
||||
|
||||
interface Emoji {
|
||||
require_colons: boolean,
|
||||
originalName: string,
|
||||
animated: boolean
|
||||
guildId: string,
|
||||
name: string,
|
||||
url: string,
|
||||
id: string,
|
||||
}
|
||||
|
||||
interface MessageObject {
|
||||
content: string,
|
||||
validNonShortcutEmojis: Emoji[]
|
||||
}
|
||||
|
||||
type SendListener = (channelId: string, messageObj: MessageObject, extra: any) => void;
|
||||
type EditListener = (channelId: string, messageId: string, messageObj: MessageObject) => void;
|
||||
|
||||
const sendListeners = new Set<SendListener>();
|
||||
const editListeners = new Set<EditListener>();
|
||||
|
||||
export function _handlePreSend(channelId: string, messageObj: MessageObject, extra: any) {
|
||||
for (const listener of sendListeners) {
|
||||
try {
|
||||
listener(channelId, messageObj, extra);
|
||||
} catch (e) { MessageEventsLogger.error(`MessageSendHandler: Listener encoutered an unknown error. (${e})`) }
|
||||
}
|
||||
}
|
||||
|
||||
export function _handlePreEdit(channeld: string, messageId: string, messageObj: MessageObject) {
|
||||
for (const listener of editListeners) {
|
||||
try {
|
||||
listener(channeld, messageId, messageObj);
|
||||
} catch (e) { MessageEventsLogger.error(`MessageEditHandler: Listener encoutered an unknown error. (${e})`) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: This event fires off before a message is sent, allowing you to edit the message.
|
||||
*/
|
||||
export function addPreSendListener(listener: SendListener) { sendListeners.add(listener) }
|
||||
/**
|
||||
* Note: This event fires off before a message's edit is applied, allowing you to further edit the message.
|
||||
*/
|
||||
export function addPreEditListener(listener: EditListener) { editListeners.add(listener) }
|
||||
export function removePreSendListener(listener: SendListener) { sendListeners.delete(listener) }
|
||||
export function removePreEditListener(listener: EditListener) { editListeners.delete(listener) }
|
||||
|
||||
// Message clicks
|
||||
type ClickListener = (message: Message, channel: Channel, event: MouseEvent) => void;
|
||||
|
||||
const listeners = new Set<ClickListener>();
|
||||
|
||||
export function _handleClick(message, channel, event) {
|
||||
for (const listener of listeners) {
|
||||
try {
|
||||
listener(message, channel, event);
|
||||
} catch (e) { MessageEventsLogger.error(`MessageClickHandler: Listener encoutered an unknown error. (${e})`) }
|
||||
}
|
||||
}
|
||||
|
||||
export function addClickListener(listener: ClickListener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
export function removeClickListener(listener: ClickListener) {
|
||||
return listeners.delete(listener);
|
||||
}
|
@ -1 +1 @@
|
||||
export * as MessageClicks from "./MessageClicks";
|
||||
export * as MessageEvents from "./MessageEvents";
|
@ -1,16 +0,0 @@
|
||||
import definePlugin from "../utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageClicksApi",
|
||||
description: "Api required by anything using message click actions",
|
||||
author: "Vendicated",
|
||||
patches: [{
|
||||
find: "if(e.altKey){",
|
||||
replacement: {
|
||||
match: /\.useClickMessage=function\((.{1,2}),(.{1,2})\).+?function\((.{1,2})\){/,
|
||||
replace: (m, message, channel, event) =>
|
||||
// the message param is shadowed by the event param, so need to alias them
|
||||
`${m.replace("{", `{var _msg=${message};var _chan=${channel};`)}Vencord.Api.MessageClicks._handleClick(_msg, _chan, ${event});`
|
||||
}
|
||||
}]
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
import definePlugin from "../utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageEventsAPI",
|
||||
description: "Api required by anything using message events.",
|
||||
author: "ArjixWasTaken",
|
||||
patches: [
|
||||
{
|
||||
find: "sendMessage:function",
|
||||
replacement: [{
|
||||
match: /(?<=sendMessage:function\(.{1,2},.{1,2},.{1,2},.{1,2}\)){/,
|
||||
replace: "{Vencord.Api.MessageEvents._handlePreSend(...arguments);"
|
||||
}, {
|
||||
match: /(?<=editMessage:function\(.{1,2},.{1,2},.{1,2}\)){/,
|
||||
replace: "{Vencord.Api.MessageEvents._handlePreEdit(...arguments);"
|
||||
}]
|
||||
},
|
||||
{
|
||||
find: "if(e.altKey){",
|
||||
replacement: {
|
||||
match: /\.useClickMessage=function\((.{1,2}),(.{1,2})\).+?function\((.{1,2})\){/,
|
||||
replace: (m, message, channel, event) =>
|
||||
// the message param is shadowed by the event param, so need to alias them
|
||||
`${m.replace("{", `{var _msg=${message};var _chan=${channel};`)}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});`
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
@ -0,0 +1,58 @@
|
||||
import { addPreSendListener, addPreEditListener } from "../api/MessageEvents";
|
||||
import { findByProps } from "../utils/webpack";
|
||||
import definePlugin from "../utils/types"
|
||||
|
||||
export default definePlugin({
|
||||
name: "Nitro Bypass",
|
||||
author: "ArjixWasTaken",
|
||||
description: "Allows you to stream in nitro quality and send fake emojis.",
|
||||
patches: [
|
||||
{
|
||||
find: `canUseAnimatedEmojis:function`,
|
||||
replacement: [
|
||||
"canUseAnimatedEmojis",
|
||||
"canUseEmojisEverywhere",
|
||||
"canUseHigherFramerate"
|
||||
].map(func => {
|
||||
return {
|
||||
match: new RegExp(`${func}:function\\(.+?}`),
|
||||
replace: `${func}:function (e) { return true; }`
|
||||
}
|
||||
})
|
||||
},
|
||||
],
|
||||
start() {
|
||||
const { getCustomEmojiById } = findByProps("getCustomEmojiById");
|
||||
|
||||
// Remove any nitro requirements for any of the streaming settings.
|
||||
findByProps("ApplicationStreamPresets")
|
||||
.ApplicationStreamSettingRequirements
|
||||
.forEach(x => {
|
||||
delete x.userPremiumType;
|
||||
delete x.guildPremiumTier
|
||||
});
|
||||
|
||||
addPreSendListener((_, messageObj) => {
|
||||
const guildId = window.location.href.split("channels/")[1].split("/")[0];
|
||||
for (const emoji of messageObj.validNonShortcutEmojis) {
|
||||
if (!emoji.require_colons) continue;
|
||||
if (emoji.guildId === guildId && !emoji.animated) continue;
|
||||
|
||||
const emojiString = `<${emoji.animated ? 'a' : ''}:${emoji.originalName || emoji.name}:${emoji.id}>`;
|
||||
const url = emoji.url.replace(/\?size=[0-9]+/, `?size=48`);
|
||||
messageObj.content = messageObj.content.replace(emojiString, ` ${url} `);
|
||||
}
|
||||
})
|
||||
addPreEditListener((_, __, messageObj) => {
|
||||
const guildId = window.location.href.split("channels/")[1].split("/")[0];
|
||||
|
||||
for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
|
||||
const emoji = getCustomEmojiById(emojiId);
|
||||
if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
|
||||
|
||||
const url = emoji.url.replace(/\?size=[0-9]+/, `?size=48`);
|
||||
messageObj.content = messageObj.content.replace(emojiStr, ` ${url} `);
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
Loading…
Reference in new issue