2023-09-05 19:42:35 +02:00
/ *
* Vencord , a modification for Discord ' s desktop app
* Copyright ( c ) 2023 Vendicated and contributors
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https : //www.gnu.org/licenses/>.
* /
2024-04-23 01:46:11 +02:00
import { definePluginSettings , migratePluginSettings } from "@api/Settings" ;
2023-09-05 19:42:35 +02:00
import { Devs } from "@utils/constants" ;
2024-07-13 19:14:22 +02:00
import definePlugin , { OptionType , PluginSettingDef } from "@utils/types" ;
const opt = ( description : string ) = > ( {
type : OptionType . BOOLEAN ,
description ,
default : true ,
restartNeeded : true
} satisfies PluginSettingDef ) ;
2023-09-05 19:42:35 +02:00
2024-04-23 01:46:11 +02:00
const settings = definePluginSettings ( {
2024-07-13 19:14:22 +02:00
showTimeouts : opt ( "Show member timeout icons in chat." ) ,
showInvitesPaused : opt ( "Show the invites paused tooltip in the server list." ) ,
showModView : opt ( "Show the member mod view context menu item in all servers." ) ,
disableDiscoveryFilters : opt ( "Disable filters in Server Discovery search that hide servers that don't meet discovery criteria." ) ,
disableDisallowedDiscoveryFilters : opt ( "Disable filters in Server Discovery search that hide NSFW & disallowed servers." ) ,
2024-04-23 01:46:11 +02:00
} ) ;
migratePluginSettings ( "ShowHiddenThings" , "ShowTimeouts" ) ;
2023-09-05 19:42:35 +02:00
export default definePlugin ( {
2024-04-23 01:46:11 +02:00
name : "ShowHiddenThings" ,
2024-05-08 03:50:26 +02:00
tags : [ "ShowTimeouts" , "ShowInvitesPaused" , "ShowModView" , "DisableDiscoveryFilters" ] ,
2024-05-13 07:09:19 +02:00
description : "Displays various hidden & moderator-only things regardless of permissions." ,
2023-09-05 19:42:35 +02:00
authors : [ Devs . Dolfies ] ,
patches : [
{
find : "showCommunicationDisabledStyles" ,
2024-04-23 01:46:11 +02:00
predicate : ( ) = > settings . store . showTimeouts ,
2023-09-05 19:42:35 +02:00
replacement : {
match : /&&\i\.\i\.canManageUser\(\i\.\i\.MODERATE_MEMBERS,\i\.author,\i\)/ ,
replace : "" ,
} ,
} ,
2024-04-23 01:46:11 +02:00
{
2024-06-19 16:45:48 +02:00
find : "2022-07_invites_disabled" ,
2024-04-23 01:46:11 +02:00
predicate : ( ) = > settings . store . showInvitesPaused ,
replacement : {
2024-06-19 16:45:48 +02:00
match : /\i\.\i\.can\(\i\.\i.MANAGE_GUILD,\i\)/ ,
2024-04-23 01:46:11 +02:00
replace : "true" ,
} ,
2024-05-08 03:50:26 +02:00
} ,
{
2024-06-19 16:45:48 +02:00
find : /context:\i,checkElevated:!1\}\),\i\.\i.{0,200}autoTrackExposure/ ,
2024-05-08 03:50:26 +02:00
predicate : ( ) = > settings . store . showModView ,
replacement : {
2024-06-19 16:45:48 +02:00
match : /return \i\.\i\(\i\.\i\(\{user:\i,context:\i,checkElevated:!1\}\),\i\.\i\)/ ,
2024-05-08 03:50:26 +02:00
replace : "return true" ,
}
} ,
2024-07-30 23:18:42 +02:00
// fixes a bug where Members page must be loaded to see highest role, why is Discord depending on MemberSafetyStore.getEnhancedMember for something that can be obtained here?
{
find : "Messages.GUILD_MEMBER_MOD_VIEW_PERMISSION_GRANTED_BY_ARIA_LABEL,tooltipContentClassName" ,
predicate : ( ) = > settings . store . showModView ,
replacement : {
match : /(role:)\i(?=,guildId.{0,100}role:(\i\[))/ ,
replace : "$1$2arguments[0].member.highestRoleId]" ,
}
} ,
2024-05-08 03:50:26 +02:00
{
2024-05-21 02:28:06 +02:00
find : "prod_discoverable_guilds" ,
2024-05-08 03:50:26 +02:00
predicate : ( ) = > settings . store . disableDiscoveryFilters ,
replacement : {
2024-05-21 02:28:06 +02:00
match : /\{"auto_removed:.*?\}/ ,
replace : "{}"
}
} ,
2024-06-19 16:45:48 +02:00
// remove the 200 server minimum
2024-05-21 02:28:06 +02:00
{
2024-06-19 16:45:48 +02:00
find : '">200"' ,
2024-05-21 02:28:06 +02:00
predicate : ( ) = > settings . store . disableDiscoveryFilters ,
replacement : {
2024-06-19 16:45:48 +02:00
match : '">200"' ,
replace : '">0"'
2024-05-08 03:50:26 +02:00
}
2024-05-13 07:09:19 +02:00
} ,
2024-06-19 16:45:48 +02:00
// empty word filter (why would anyone search "horny" in fucking server discovery... please... why are we patching this again??)
2024-05-13 07:09:19 +02:00
{
2024-06-19 16:45:48 +02:00
find : '"horny","fart"' ,
2024-05-13 07:09:19 +02:00
predicate : ( ) = > settings . store . disableDisallowedDiscoveryFilters ,
replacement : {
2024-06-19 16:45:48 +02:00
match : /=\["egirl",.+?\]/ ,
replace : "=[]"
2024-05-13 07:09:19 +02:00
}
} ,
2024-06-26 13:03:23 +02:00
// empty 2nd word filter
{
find : '"pepe","nude"' ,
predicate : ( ) = > settings . store . disableDisallowedDiscoveryFilters ,
replacement : {
2024-06-28 05:53:09 +02:00
match : /(?<=[?=])\["pepe",.+?\]/ ,
replace : "[]" ,
2024-06-26 13:03:23 +02:00
} ,
} ,
2024-06-19 16:45:48 +02:00
// patch request that queries if term is allowed
2024-05-13 07:09:19 +02:00
{
2024-06-19 16:45:48 +02:00
find : ".GUILD_DISCOVERY_VALID_TERM" ,
2024-05-13 07:09:19 +02:00
predicate : ( ) = > settings . store . disableDisallowedDiscoveryFilters ,
all : true ,
replacement : {
2024-06-19 16:45:48 +02:00
match : /\i\.\i\.get\(\{url:\i\.\i\.GUILD_DISCOVERY_VALID_TERM,query:\{term:\i\},oldFormErrors:!0\}\);/g ,
2024-05-13 07:09:19 +02:00
replace : "Promise.resolve({ body: { valid: true } });"
}
2024-04-23 01:46:11 +02:00
}
2023-09-05 19:42:35 +02:00
] ,
2024-04-23 01:46:11 +02:00
settings ,
2023-09-05 19:42:35 +02:00
} ) ;