1
0
Fork 0
mirror of https://github.com/NovaGM/Modules.git synced 2024-08-14 22:47:01 +00:00

Fixed FreeNitro.

This commit is contained in:
Keanu Timmermans 2021-03-22 14:46:52 +01:00
parent d912fbb7b7
commit 3da9848a0e
Signed by: keanucode
GPG key ID: A7431C0D513CA93B
2 changed files with 68 additions and 53 deletions

View file

@ -7,5 +7,5 @@
"authors": ["189079074054995969"], "authors": ["189079074054995969"],
"version": "1.0.0" "version": "1.1.0"
} }

View file

@ -1,42 +1,57 @@
import * as webpackModules from "@goosemod/webpack"; import * as webpackModules from '@goosemod/webpack';
var filterExternalHook; var searchHook;
var parseHook; var parseHook;
var useEmojiSelectHandlerHook; var useEmojiSelectHandlerHook;
const emojisModule = webpackModules.findByProps('getDisambiguatedEmojiContext', 'filterExternal'); const emojisModule = webpackModules.findByProps('getDisambiguatedEmojiContext', 'search');
const messageEmojiParserModule = webpackModules.findByProps('parse', 'parsePreprocessor', 'unparse'); const messageEmojiParserModule = webpackModules.findByProps(
'parse',
'parsePreprocessor',
'unparse',
);
const emojiPickerModule = webpackModules.findByProps('useEmojiSelectHandler'); const emojiPickerModule = webpackModules.findByProps('useEmojiSelectHandler');
let originalFunctions = { let originalFunctions = {
original_filterExternal: undefined, original_search: undefined,
original_parse: undefined, original_parse: undefined,
original_useEmojiSelectHandler: undefined original_useEmojiSelectHandler: undefined,
}; };
export default { export default {
goosemodHandlers: { goosemodHandlers: {
onImport: async () => { onImport: async () => {
filterExternalHook = originalFunctions.original_filterExternal = emojisModule.filterExternal; searchHook = originalFunctions.original_search = emojisModule.search;
emojisModule.filterExternal = function() { return filterExternalHook.apply(this, arguments); }; emojisModule.search = function () {
return searchHook.apply(this, arguments);
};
parseHook = originalFunctions.original_parse = messageEmojiParserModule.parse; parseHook = originalFunctions.original_parse = messageEmojiParserModule.parse;
messageEmojiParserModule.parse = function() { return parseHook.apply(this, arguments); }; messageEmojiParserModule.parse = function () {
return parseHook.apply(this, arguments);
};
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler = emojiPickerModule.useEmojiSelectHandler; useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler =
emojiPickerModule.useEmojiSelectHandler = function() { return useEmojiSelectHandlerHook.apply(this, arguments); }; emojiPickerModule.useEmojiSelectHandler;
emojiPickerModule.useEmojiSelectHandler = function () {
return useEmojiSelectHandlerHook.apply(this, arguments);
};
filterExternalHook = function(guild, query, n) { searchHook = function () {
let emojis = emojisModule.getDisambiguatedEmojiContext(guild ? guild.guild_id : null).nameMatchesChain(query); let result = originalFunctions.original_search.apply(this, arguments);
if(n > 0) emojis = emojis.take(n); result.unlocked.push(...result.locked);
return emojis.value(); result.locked = [];
} return result;
};
parseHook = function () { parseHook = function () {
let result = originalFunctions.original_parse.apply(this, arguments); let result = originalFunctions.original_parse.apply(this, arguments);
if (result.invalidEmojis.length !== 0) { if (result.invalidEmojis.length !== 0) {
for (let emoji of result.invalidEmojis) { for (let emoji of result.invalidEmojis) {
result.content = result.content.replace(`<${emoji.animated ? "a" : ""}:${emoji.originalName || emoji.name}:${emoji.id}>`, `${emoji.url}&size=64&width=16`); result.content = result.content.replace(
`<${emoji.animated ? 'a' : ''}:${emoji.originalName || emoji.name}:${emoji.id}>`,
`${emoji.url}&size=64&width=16`,
);
} }
result.invalidEmojis = []; result.invalidEmojis = [];
} }
@ -56,9 +71,9 @@ export default {
}, },
onRemove: async () => { onRemove: async () => {
filterExternalHook = originalFunctions.original_filterExternal; searchHook = originalFunctions.original_search;
parseHook = originalFunctions.original_parse; parseHook = originalFunctions.original_parse;
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler; useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler;
} },
} },
}; };