diff --git a/manifest.json b/manifest.json index 1e3658c..188e34f 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "github": "Penguin-Spy" }, "source": "https://github.com/Penguin-Spy/replugged-pronoundb", - "version": "1.3.5", + "version": "1.3.6", "updater": { "type": "store", "id": "dev.penguinspy.pronoundb" diff --git a/package.json b/package.json index 5cb71a2..c030663 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "replugged-pronoundb", - "version": "1.3.5", + "version": "1.3.6", "description": "Shows users' PronounDB pronouns in chat so that you don't accidentally misgender people.", "author": "Penguin_Spy", "scripts": { diff --git a/src/discordPronouns.js b/src/discordPronouns.js index 48b0d3d..e7fbacd 100644 --- a/src/discordPronouns.js +++ b/src/discordPronouns.js @@ -2,7 +2,8 @@ import { getByProps, getBySource, getFunctionBySource } from "replugged/webpack" export const UserProfileStore = getByProps("getUserProfile") const { getUserProfile, getGuildMemberProfile } = UserProfileStore -const fetchUserProfile = getFunctionBySource(getBySource(/withMutualGuilds,.=.\.withMutualFriendsCount,.=.\.guildId/), "apply") +//const fetchUserProfile = getFunctionBySource(getBySource(/withMutualGuilds,.=.\.withMutualFriendsCount,.=.\.guildId/), "apply") +const { fetchProfile } = getByProps("fetchProfile") // wait 750 ms between queue processes (it's basically impossible to get rate-limited with this delay) const QUEUE_PROCESS_DELAY = 750 @@ -12,9 +13,9 @@ const queuedProfiles = [] let queueTimeout = undefined // processes one item in the queue, and sets the timeout again if it's not empty -function fetchProfile() { +function processFetchQueue() { const [user_id, guild_id] = queuedProfiles.pop().split("-") - fetchUserProfile(user_id, { // this (discord) function fetches the profile and dispatches it to the UserProfileStore + fetchProfile(user_id, { // this (discord) function fetches the profile and dispatches it to the UserProfileStore guildId: guild_id !== "null" ? guild_id : undefined, // don't send the string "null" (when in DMs) withMutualFriendsCount: false, // these 2 params match what discord sets them to when clicking on the profile withMutualGuilds: true @@ -23,7 +24,7 @@ function fetchProfile() { // if there are more profiles to fetch, set the timeout again if(queuedProfiles.length > 0) { - queueTimeout = setTimeout(fetchProfile, QUEUE_PROCESS_DELAY) + queueTimeout = setTimeout(processFetchQueue, QUEUE_PROCESS_DELAY) } } @@ -36,7 +37,7 @@ export function usePronouns(user_id, guild_id) { queuedProfiles.push(profileIdentifier) if(!queueTimeout) { // only set the timeout if it's not set yet - queueTimeout = setTimeout(fetchProfile, QUEUE_PROCESS_DELAY) + queueTimeout = setTimeout(processFetchQueue, QUEUE_PROCESS_DELAY) } } diff --git a/src/index.js b/src/index.js index 83f765b..5657802 100644 --- a/src/index.js +++ b/src/index.js @@ -15,11 +15,9 @@ const settings = await SettingsManager.init(PLUGIN_ID, DefaultSettings) export async function start() { // pronouns in message header if(settings.get("show_in_chat")) { - webpack.waitForModule(webpack.filters.bySource(/.=.\.renderPopout,.=.\.renderRemixTag,/)) + webpack.waitForModule(webpack.filters.byProps("UsernameDecorationTypes")) .then(MessageHeaderUsername => { - const functionKey = Object.entries(MessageHeaderUsername).find(e => typeof e[1] === "function")[0] - - inject.after(MessageHeaderUsername, functionKey, ([props], res) => { + inject.after(MessageHeaderUsername, "default", ([props], res) => { if(props.message.author.bot) { return } // bots can never have pronouns (transphobic?), and trying to render them makes an invalid API call to Discord const headerItems = res.props.children diff --git a/src/style.css b/src/style.css index 275e0b0..3866c1e 100644 --- a/src/style.css +++ b/src/style.css @@ -48,3 +48,6 @@ span[id^="message-username-"]:not(:hover) > :is( .pronoundb-settings-notice { margin-bottom: 20px; } +.pronoundb-settings-notice a:hover { + text-decoration: underline; +}