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

@ -36,7 +36,7 @@ export default definePlugin({
replacement: {
match: /uploadFiles:(.{1,2}),/,
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)),",
},
},
],

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

@ -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",
replacement: {
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'}",
},
},
{

@ -75,7 +75,7 @@ export default definePlugin({
find: ".renderConnectionStatus=",
replacement: {
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) {

@ -187,7 +187,7 @@ export default definePlugin({
find: "open-native-link",
replacement: {
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])"
},
},

@ -30,7 +30,7 @@ export default definePlugin({
find: ".renderOwner=",
replacement: {
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&&"
}
},
],

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

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

@ -99,7 +99,7 @@ export default definePlugin({
find: ".isSidebarVisible,",
replacement: {
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"
}
}],

@ -151,7 +151,7 @@ export default definePlugin({
replace:
"MESSAGE_DELETE:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
" cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, false);" +
" cache = $self.handleDelete(cache, $1, false);" +
" $2commit(cache);" +
"},"
},
@ -161,7 +161,7 @@ export default definePlugin({
replace:
"MESSAGE_DELETE_BULK:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
" cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, true);" +
" cache = $self.handleDelete(cache, $1, true);" +
" $2commit(cache);" +
"},"
},
@ -171,7 +171,7 @@ export default definePlugin({
replace: "$1" +
".update($3,m =>" +
" $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" +
")" +
".update($3"
@ -287,7 +287,7 @@ export default definePlugin({
{
// Render editHistory in the deepest div for message content
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), "
}
]
},

@ -43,7 +43,7 @@ export default definePlugin({
replacement: [
{
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;"
}
]
}

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

@ -38,7 +38,7 @@ export default definePlugin({
find: "showCommunicationDisabledStyles",
replacement: {
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
@ -46,7 +46,7 @@ export default definePlugin({
find: ".Messages.BOT_PROFILE_SLASH_COMMANDS",
replacement: {
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

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

@ -55,7 +55,7 @@ export default definePlugin({
// return React.createElement(AccountPanel, { ..., showTaglessAccountPanel: blah })
match: /return ?(.{0,30}\(.{1,3},\{[^}]+?,showTaglessAccountPanel:.+?\}\))/,
// 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)

@ -29,7 +29,7 @@ export default definePlugin({
find: "PAYMENT_FLOW_MODAL_TEST_PAGE,",
replacement: {
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)

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

@ -79,7 +79,7 @@ export default new class ViewIcons implements PluginDef {
},
{
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"
}
]
}

@ -92,7 +92,7 @@ export default definePlugin({
find: ",reactionRef:",
replacement: {
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)"
}
}],