refactor: update plugins to use $self (#478)

Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
fawn 2023-02-10 21:41:49 +00:00 committed by GitHub
parent 1d995e58f5
commit d95be1acba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 26 additions and 26 deletions

View file

@ -36,7 +36,7 @@ export default definePlugin({
replacement: { replacement: {
match: /uploadFiles:(.{1,2}),/, match: /uploadFiles:(.{1,2}),/,
replace: replace:
"uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=Vencord.Plugins.plugins.AnonymiseFileNames.anonymise(f.filename)),$1(...args)),", "uploadFiles:(...args)=>(args[0].uploads.forEach(f=>f.filename=$self.anonymise(f.filename)),$1(...args)),",
}, },
}, },
], ],

View file

@ -31,7 +31,7 @@ export default definePlugin({
replacement: { replacement: {
match: /(return.{0,10}\.jsx.{0,50}isWindowFocused)/, match: /(return.{0,10}\.jsx.{0,50}isWindowFocused)/,
replace: replace:
"Vencord.Plugins.plugins.BetterGifAltText.altify(e);$1", "$self.altify(e);$1",
}, },
}, },
{ {
@ -39,7 +39,7 @@ export default definePlugin({
replacement: { replacement: {
match: /(?<==(.{1,3})\.alt.{0,20})\?.{0,5}\.Messages\.GIF/, match: /(?<==(.{1,3})\.alt.{0,20})\?.{0,5}\.Messages\.GIF/,
replace: replace:
"?($1.alt='GIF',Vencord.Plugins.plugins.BetterGifAltText.altify($1))", "?($1.alt='GIF',$self.altify($1))",
}, },
}, },
], ],

View file

@ -33,7 +33,7 @@ export default definePlugin({
find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z", find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z",
replacement: { replacement: {
match: /viewBox:"0 0 20 20"/, match: /viewBox:"0 0 20 20"/,
replace: "$&,onClick:()=>Vencord.Plugins.plugins.BetterRoleDot.copyToClipBoard(e.color),style:{cursor:'pointer'}", replace: "$&,onClick:()=>$self.copyToClipBoard(e.color),style:{cursor:'pointer'}",
}, },
}, },
{ {

View file

@ -75,7 +75,7 @@ export default definePlugin({
find: ".renderConnectionStatus=", find: ".renderConnectionStatus=",
replacement: { replacement: {
match: /(?<=renderConnectionStatus=.+\.channel,children:)\w/, match: /(?<=renderConnectionStatus=.+\.channel,children:)\w/,
replace: "[$&, Vencord.Plugins.plugins.CallTimer.renderTimer(this.props.channel.id)]" replace: "[$&, $self.renderTimer(this.props.channel.id)]"
} }
}], }],
renderTimer(channelId: string) { renderTimer(channelId: string) {

View file

@ -187,7 +187,7 @@ export default definePlugin({
find: "open-native-link", find: "open-native-link",
replacement: { replacement: {
match: /id:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\},"open-native-link"\)/, match: /id:"open-native-link".{0,200}\(\{href:(.{0,3}),.{0,200}\},"open-native-link"\)/,
replace: "$&,Vencord.Plugins.plugins.EmoteCloner.makeMenu(arguments[2])" replace: "$&,$self.makeMenu(arguments[2])"
}, },
}, },

View file

@ -30,7 +30,7 @@ export default definePlugin({
find: ".renderOwner=", find: ".renderOwner=",
replacement: { replacement: {
match: /isOwner;return null!=(\w+)?&&/g, match: /isOwner;return null!=(\w+)?&&/g,
replace: "isOwner;if(Vencord.Plugins.plugins.ForceOwnerCrown.isGuildOwner(this.props)){$1=true;}return null!=$1&&" replace: "isOwner;if($self.isGuildOwner(this.props)){$1=true;}return null!=$1&&"
} }
}, },
], ],

View file

@ -146,19 +146,19 @@ export default definePlugin({
find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY", find: ".Messages.SETTINGS_GAMES_TOGGLE_OVERLAY",
replacement: { replacement: {
match: /var .=(?<props>.)\.overlay.+?"aria-label":.\..\.Messages\.SETTINGS_GAMES_TOGGLE_OVERLAY.+?}}\)/, match: /var .=(?<props>.)\.overlay.+?"aria-label":.\..\.Messages\.SETTINGS_GAMES_TOGGLE_OVERLAY.+?}}\)/,
replace: "$&,Vencord.Plugins.plugins.IgnoreActivities.renderToggleGameActivityButton($<props>)" replace: "$&,$self.renderToggleGameActivityButton($<props>)"
} }
}, { }, {
find: ".overlayBadge", find: ".overlayBadge",
replacement: { replacement: {
match: /.badgeContainer.+?.\?\(0,.\.jsx\)\(.{1,2},{name:(?<props>.)\.name}\):null/, match: /.badgeContainer.+?.\?\(0,.\.jsx\)\(.{1,2},{name:(?<props>.)\.name}\):null/,
replace: "$&,Vencord.Plugins.plugins.IgnoreActivities.renderToggleActivityButton($<props>)" replace: "$&,$self.renderToggleActivityButton($<props>)"
} }
}, { }, {
find: '.displayName="LocalActivityStore"', find: '.displayName="LocalActivityStore"',
replacement: { replacement: {
match: /(?<activities>.)\.push\(.\({type:.\..{1,3}\.LISTENING.+?\)\)/, match: /(?<activities>.)\.push\(.\({type:.\..{1,3}\.LISTENING.+?\)\)/,
replace: "$&;$<activities>=$<activities>.filter(Vencord.Plugins.plugins.IgnoreActivities.isActivityNotIgnored);" replace: "$&;$<activities>=$<activities>.filter($self.isActivityNotIgnored);"
} }
}], }],

View file

@ -68,7 +68,7 @@ export default definePlugin({
find: ".LOADING_DID_YOU_KNOW", find: ".LOADING_DID_YOU_KNOW",
replacement: { replacement: {
match: /\._loadingText=.+?random\(.+?;/s, match: /\._loadingText=.+?random\(.+?;/s,
replace: "._loadingText=Vencord.Plugins.plugins.LoadingQuotes.quote;", replace: "._loadingText=$self.quote;",
}, },
}, },
], ],

View file

@ -99,7 +99,7 @@ export default definePlugin({
find: ".isSidebarVisible,", find: ".isSidebarVisible,",
replacement: { replacement: {
match: /(var (.)=.\.className.+?children):\[(.\.useMemo[^}]+"aria-multiselectable")/, match: /(var (.)=.\.className.+?children):\[(.\.useMemo[^}]+"aria-multiselectable")/,
replace: "$1:[$2.startsWith('members')?Vencord.Plugins.plugins.MemberCount.render():null,$3" replace: "$1:[$2.startsWith('members')?$self.render():null,$3"
} }
}], }],

View file

@ -151,7 +151,7 @@ export default definePlugin({
replace: replace:
"MESSAGE_DELETE:function($1){" + "MESSAGE_DELETE:function($1){" +
" var cache = $2getOrCreate($1.channelId);" + " var cache = $2getOrCreate($1.channelId);" +
" cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, false);" + " cache = $self.handleDelete(cache, $1, false);" +
" $2commit(cache);" + " $2commit(cache);" +
"}," "},"
}, },
@ -161,7 +161,7 @@ export default definePlugin({
replace: replace:
"MESSAGE_DELETE_BULK:function($1){" + "MESSAGE_DELETE_BULK:function($1){" +
" var cache = $2getOrCreate($1.channelId);" + " var cache = $2getOrCreate($1.channelId);" +
" cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, true);" + " cache = $self.handleDelete(cache, $1, true);" +
" $2commit(cache);" + " $2commit(cache);" +
"}," "},"
}, },
@ -171,7 +171,7 @@ export default definePlugin({
replace: "$1" + replace: "$1" +
".update($3,m =>" + ".update($3,m =>" +
" $2.message.content !== m.editHistory?.[0]?.content && $2.message.content !== m.content ?" + " $2.message.content !== m.editHistory?.[0]?.content && $2.message.content !== m.content ?" +
" m.set('editHistory',[...(m.editHistory || []), Vencord.Plugins.plugins.MessageLogger.makeEdit($2.message, m)]) :" + " m.set('editHistory',[...(m.editHistory || []), $self.makeEdit($2.message, m)]) :" +
" m" + " m" +
")" + ")" +
".update($3" ".update($3"
@ -287,7 +287,7 @@ export default definePlugin({
{ {
// Render editHistory in the deepest div for message content // Render editHistory in the deepest div for message content
match: /(\)\("div",\{id:.+?children:\[)/, match: /(\)\("div",\{id:.+?children:\[)/,
replace: "$1 (arguments[0].message.editHistory.length > 0 ? arguments[0].message.editHistory.map(edit => Vencord.Plugins.plugins.MessageLogger.renderEdit(edit)) : null), " replace: "$1 (arguments[0].message.editHistory.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), "
} }
] ]
}, },

View file

@ -43,7 +43,7 @@ export default definePlugin({
replacement: [ replacement: [
{ {
match: /(?<=MESSAGE_CREATE:function\((\w)\){var \w=\w\.channelId,\w=\w\.message,\w=\w\.isPushNotification,\w=\w\.\w\.getOrCreate\(\w\));/, match: /(?<=MESSAGE_CREATE:function\((\w)\){var \w=\w\.channelId,\w=\w\.message,\w=\w\.isPushNotification,\w=\w\.\w\.getOrCreate\(\w\));/,
replace: ";if(Vencord.Plugins.plugins.NoBlockedMessages.isBlocked(n))return;" replace: ";if($self.isBlocked(n))return;"
} }
] ]
} }

View file

@ -51,7 +51,7 @@ export default definePlugin({
replacement: { replacement: {
match: /CREATE_PENDING_REPLY:function\((.{1,2})\){/, match: /CREATE_PENDING_REPLY:function\((.{1,2})\){/,
replace: replace:
"CREATE_PENDING_REPLY:function($1){$1.shouldMention=Vencord.Plugins.plugins.NoReplyMention.shouldMention($1);", "CREATE_PENDING_REPLY:function($1){$1.shouldMention=$self.shouldMention($1);",
}, },
}, },
], ],

View file

@ -38,7 +38,7 @@ export default definePlugin({
find: "showCommunicationDisabledStyles", find: "showCommunicationDisabledStyles",
replacement: { replacement: {
match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/, match: /(?<=return\s*\(0,\w{1,3}\.jsxs?\)\(.+!\w{1,3}&&)(\(0,\w{1,3}.jsxs?\)\(.+?\{.+?\}\))/,
replace: "[$1, Vencord.Plugins.plugins.PronounDB.PronounsChatComponent(e)]" replace: "[$1, $self.PronounsChatComponent(e)]"
} }
}, },
// Hijack the discord pronouns section (hidden without experiment) and add a wrapper around the text section // Hijack the discord pronouns section (hidden without experiment) and add a wrapper around the text section
@ -46,7 +46,7 @@ export default definePlugin({
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
replacement: { replacement: {
match: /\(0,.\.jsx\)\((?<PronounComponent>.{1,2}\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>.{1,2})\.pronouns.+?})\)/, match: /\(0,.\.jsx\)\((?<PronounComponent>.{1,2}\..),(?<pronounProps>{currentPronouns.+?:(?<fullProps>.{1,2})\.pronouns.+?})\)/,
replace: "$<fullProps>&&Vencord.Plugins.plugins.PronounDB.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)" replace: "$<fullProps>&&$self.PronounsProfileWrapper($<PronounComponent>,$<pronounProps>,$<fullProps>)"
} }
}, },
// Make pronouns experiment be enabled by default // Make pronouns experiment be enabled by default

View file

@ -37,7 +37,7 @@ export default definePlugin({
find: "disableBorderColor:!0", find: "disableBorderColor:!0",
replacement: { replacement: {
match: /\(.{0,10}\{user:(.),setNote:.,canDM:.,.+?\}\)/, match: /\(.{0,10}\{user:(.),setNote:.,canDM:.,.+?\}\)/,
replace: "$&,Vencord.Plugins.plugins.ReviewDB.getReviewsComponent($1)" replace: "$&,$self.getReviewsComponent($1)"
}, },
} }
], ],

View file

@ -55,7 +55,7 @@ export default definePlugin({
// return React.createElement(AccountPanel, { ..., showTaglessAccountPanel: blah }) // return React.createElement(AccountPanel, { ..., showTaglessAccountPanel: blah })
match: /return ?(.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/, match: /return ?(.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/,
// return [Player, Panel] // return [Player, Panel]
replace: "return [Vencord.Plugins.plugins.SpotifyControls.renderPlayer(),$1]" replace: "return [$self.renderPlayer(),$1]"
} }
}, },
// Adds POST and a Marker to the SpotifyAPI (so we can easily find it) // Adds POST and a Marker to the SpotifyAPI (so we can easily find it)

View file

@ -29,7 +29,7 @@ export default definePlugin({
find: "PAYMENT_FLOW_MODAL_TEST_PAGE,", find: "PAYMENT_FLOW_MODAL_TEST_PAGE,",
replacement: { replacement: {
match: /{section:.{1,2}\..{1,3}\.PAYMENT_FLOW_MODAL_TEST_PAGE/, match: /{section:.{1,2}\..{1,3}\.PAYMENT_FLOW_MODAL_TEST_PAGE/,
replace: '{section:"StartupTimings",label:"Startup Timings",element:Vencord.Plugins.plugins.StartupTimings.StartupTimingPage},$&' replace: '{section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage},$&'
} }
}], }],
StartupTimingPage: LazyComponent(() => require("./StartupTimingPage").default) StartupTimingPage: LazyComponent(() => require("./StartupTimingPage").default)

View file

@ -42,7 +42,7 @@ export default definePlugin({
// voice/stage channels // voice/stage channels
{ {
match: /onClick:function\(\)\{(e\.handleClick.+?)}/g, match: /onClick:function\(\)\{(e\.handleClick.+?)}/g,
replace: "onClick:function(){Vencord.Plugins.plugins.VoiceChatDoubleClick.schedule(()=>{$1},e)}", replace: "onClick:function(){$self.schedule(()=>{$1},e)}",
}, },
], ],
}, },

View file

@ -79,7 +79,7 @@ export default new class ViewIcons implements PluginDef {
}, },
{ {
match: /(id:"leave-guild".{0,200}),(\(0,.{1,3}\.jsxs?\).{0,200}function)/, match: /(id:"leave-guild".{0,200}),(\(0,.{1,3}\.jsxs?\).{0,200}function)/,
replace: "$1,Vencord.Plugins.plugins.ViewIcons.buildGuildContextMenuEntries(_guild),$2" replace: "$1,$self.buildGuildContextMenuEntries(_guild),$2"
} }
] ]
} }

View file

@ -92,7 +92,7 @@ export default definePlugin({
find: ",reactionRef:", find: ",reactionRef:",
replacement: { replacement: {
match: /((.)=(.{1,3})\.hideCount)(,.+?reactionCount.+?\}\))/, match: /((.)=(.{1,3})\.hideCount)(,.+?reactionCount.+?\}\))/,
replace: "$1,whoReactedProps=$3$4,$2?null:Vencord.Plugins.plugins.WhoReacted.renderUsers(whoReactedProps)" replace: "$1,whoReactedProps=$3$4,$2?null:$self.renderUsers(whoReactedProps)"
} }
}], }],