mirror of
https://github.com/NovaGM/Modules.git
synced 2024-08-14 22:47:01 +00:00
Fixed FreeNitro.
This commit is contained in:
parent
d912fbb7b7
commit
3da9848a0e
2 changed files with 68 additions and 53 deletions
|
@ -7,5 +7,5 @@
|
|||
|
||||
"authors": ["189079074054995969"],
|
||||
|
||||
"version": "1.0.0"
|
||||
"version": "1.1.0"
|
||||
}
|
||||
|
|
|
@ -1,64 +1,79 @@
|
|||
import * as webpackModules from "@goosemod/webpack";
|
||||
import * as webpackModules from '@goosemod/webpack';
|
||||
|
||||
var filterExternalHook;
|
||||
var searchHook;
|
||||
var parseHook;
|
||||
var useEmojiSelectHandlerHook;
|
||||
|
||||
const emojisModule = webpackModules.findByProps('getDisambiguatedEmojiContext', 'filterExternal');
|
||||
const messageEmojiParserModule = webpackModules.findByProps('parse', 'parsePreprocessor', 'unparse');
|
||||
const emojisModule = webpackModules.findByProps('getDisambiguatedEmojiContext', 'search');
|
||||
const messageEmojiParserModule = webpackModules.findByProps(
|
||||
'parse',
|
||||
'parsePreprocessor',
|
||||
'unparse',
|
||||
);
|
||||
const emojiPickerModule = webpackModules.findByProps('useEmojiSelectHandler');
|
||||
|
||||
let originalFunctions = {
|
||||
original_filterExternal: undefined,
|
||||
original_parse: undefined,
|
||||
original_useEmojiSelectHandler: undefined
|
||||
original_search: undefined,
|
||||
original_parse: undefined,
|
||||
original_useEmojiSelectHandler: undefined,
|
||||
};
|
||||
|
||||
export default {
|
||||
goosemodHandlers: {
|
||||
onImport: async () => {
|
||||
filterExternalHook = originalFunctions.original_filterExternal = emojisModule.filterExternal;
|
||||
emojisModule.filterExternal = function() { return filterExternalHook.apply(this, arguments); };
|
||||
|
||||
parseHook = originalFunctions.original_parse = messageEmojiParserModule.parse;
|
||||
messageEmojiParserModule.parse = function() { return parseHook.apply(this, arguments); };
|
||||
|
||||
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler = emojiPickerModule.useEmojiSelectHandler;
|
||||
emojiPickerModule.useEmojiSelectHandler = function() { return useEmojiSelectHandlerHook.apply(this, arguments); };
|
||||
|
||||
filterExternalHook = function(guild, query, n) {
|
||||
let emojis = emojisModule.getDisambiguatedEmojiContext(guild ? guild.guild_id : null).nameMatchesChain(query);
|
||||
if(n > 0) emojis = emojis.take(n);
|
||||
return emojis.value();
|
||||
}
|
||||
|
||||
parseHook = function() {
|
||||
let result = originalFunctions.original_parse.apply(this, arguments);
|
||||
if(result.invalidEmojis.length !== 0) {
|
||||
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.invalidEmojis = [];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
useEmojiSelectHandlerHook = function(args) {
|
||||
const { onSelectEmoji, closePopout } = args;
|
||||
return function(data, state) {
|
||||
const emoji = data.emoji;
|
||||
if(emoji != null && emoji.available) {
|
||||
onSelectEmoji(emoji, state.isFinalSelection);
|
||||
if(state.isFinalSelection) closePopout();
|
||||
}
|
||||
};
|
||||
};
|
||||
},
|
||||
goosemodHandlers: {
|
||||
onImport: async () => {
|
||||
searchHook = originalFunctions.original_search = emojisModule.search;
|
||||
emojisModule.search = function () {
|
||||
return searchHook.apply(this, arguments);
|
||||
};
|
||||
|
||||
onRemove: async () => {
|
||||
filterExternalHook = originalFunctions.original_filterExternal;
|
||||
parseHook = originalFunctions.original_parse;
|
||||
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler;
|
||||
}
|
||||
}
|
||||
parseHook = originalFunctions.original_parse = messageEmojiParserModule.parse;
|
||||
messageEmojiParserModule.parse = function () {
|
||||
return parseHook.apply(this, arguments);
|
||||
};
|
||||
|
||||
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler =
|
||||
emojiPickerModule.useEmojiSelectHandler;
|
||||
emojiPickerModule.useEmojiSelectHandler = function () {
|
||||
return useEmojiSelectHandlerHook.apply(this, arguments);
|
||||
};
|
||||
|
||||
searchHook = function () {
|
||||
let result = originalFunctions.original_search.apply(this, arguments);
|
||||
result.unlocked.push(...result.locked);
|
||||
result.locked = [];
|
||||
return result;
|
||||
};
|
||||
|
||||
parseHook = function () {
|
||||
let result = originalFunctions.original_parse.apply(this, arguments);
|
||||
if (result.invalidEmojis.length !== 0) {
|
||||
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.invalidEmojis = [];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
useEmojiSelectHandlerHook = function (args) {
|
||||
const { onSelectEmoji, closePopout } = args;
|
||||
return function (data, state) {
|
||||
const emoji = data.emoji;
|
||||
if (emoji != null && emoji.available) {
|
||||
onSelectEmoji(emoji, state.isFinalSelection);
|
||||
if (state.isFinalSelection) closePopout();
|
||||
}
|
||||
};
|
||||
};
|
||||
},
|
||||
|
||||
onRemove: async () => {
|
||||
searchHook = originalFunctions.original_search;
|
||||
parseHook = originalFunctions.original_parse;
|
||||
useEmojiSelectHandlerHook = originalFunctions.original_useEmojiSelectHandler;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue