5 lines
27 KiB
JavaScript
5 lines
27 KiB
JavaScript
(function(_,A,s,a,v,pe,g,x,y,M,U){"use strict";function H(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function J(e,t,n){return t&&Y(e.prototype,t),n&&Y(e,n),e}const E=pe.storage;var f=function(e){return e.Useful="Useful",e.Fixes="Fixes",e.Fun="Fun",e}({});let ge=function(){function e(){H(this,e),this.store=[]}return J(e,[{key:"add",value:function(t){this.store.push(t)}},{key:"unpatch",value:function(){for(const t of this.store)try{t()}catch{}this.store=[]}}]),e}(),S=function(){function e({id:t,label:n,meta:r,settings:i,handlers:o}){H(this,e),this.id=t,this.label=n,this.meta=r,this.settings=i??{},this.handlers=o,this.errors={},this.patches=new ge,this.started=!1,this.listeners=new Set}return J(e,[{key:"storage",get:function(){const t=Object.fromEntries(Object.entries(this.settings).filter(function([,n]){return"default"in n}).map(function([n,r]){return[n,r.default]}));E.modules[this.id]??={enabled:!1,options:t};for(const[n,r]of Object.entries(t)){const i=E.modules[this.id].options;typeof r!=typeof i[n]&&(i[n]=r)}return E.modules[this.id]}},{key:"toggle",value:function(){this.storage.enabled=!this.storage.enabled,this.storage.enabled?this.start():this.stop(),this.refresh()}},{key:"restart",value:function(){this.started&&(this.stop(),this.start(),this.refresh())}},{key:"start",value:function(){if(!this.started){try{this.started=!0,this.handlers.onStart.call(this)}catch(t){this.stop(),this.started=!1;const n=t instanceof Error?t:new Error(String(t));A.logger.error(`[RoseUtils/${this.label}] Failed to start: ${n}`),this.errors.Start=String(n.stack??n),g.showToast(`${this.label} failed to start - see RoseUtils settings for details`,void 0)}this.refresh()}}},{key:"stop",value:function(){if(this.started){try{this.started=!1,this.handlers.onStop.call(this)}catch(t){const n=t instanceof Error?t:new Error(String(t));A.logger.error(`[RoseUtils/${this.label}] Failed to stop cleanly: ${n}`),this.errors.Stop=String(n.stack??n)}finally{this.patches.unpatch()}this.refresh()}}},{key:"refresh",value:function(){this.listeners.forEach(function(t){return t()})}},{key:"useRefresh",value:function(){var t=this;const[,n]=a.React.useReducer(function(r){return~r},0);a.React.useEffect(function(){return t.listeners.add(n),function(){t.listeners.delete(n)}},[])}}]),e}();var ye="d170a10bd3781e4a.png";function k(e,t,n=!1){const r=function(...i){n&&a.FluxDispatcher.unsubscribe(e,r),t(...i)};return a.FluxDispatcher.subscribe(e,r),function(){return a.FluxDispatcher.unsubscribe(e,r)}}const he=s.findByStoreName("SpotifyProtocolStore"),T=s.findByStoreName("SpotifyStore"),be=s.findByStoreName("UserStore"),{play:K,sync:O}=s.findByProps("play","sync")??{};function ve(e,t,n){if(typeof e=="string")return g.showToast(e,void 0);if(!K||!O)return g.showToast("Couldn't find Spotify's sync action - this feature may be unavailable on your Discord version.",void 0);if(T?.getActivity())return O(t,n);k("SPOTIFY_PLAYER_STATE",function(){return O(t,n)},!0),K(t,n)}function Se(e){const[t,n]=a.React.useReducer(function(c){return~c},0);a.React.useEffect(function(){return k("SPOTIFY_PLAYER_STATE",n)});const r=e.party.id.split(":")[1],i=a.React.useMemo(function(){const c=be?.getCurrentUser?.()?.id,l=T?.getActivity?.(),d=!!T?.hasConnectedAccount?.(),u=!!T?.getActiveSocketAndDevice?.()||!!he?.isProtocolRegistered?.();return{isYou:c===r,isListeningAlong:l?.party?.id===e.party.id,isPlayable:d&&u}},[r,e,t]);let o=!1;return i.isYou?o="Listen along with someone else, not yourself.":i.isListeningAlong?o="You're already along for this ride.":i.isPlayable||(o="Spotify is not detected"),{disabled:o,userId:r}}function me(){const[e,t]=a.React.useState(!1);return{loading:e,trigger:function(){return t(!0),setTimeout(function(){return t(!1)},5e3)}}}function Re({button:e,activity:t}){const{disabled:n,userId:r}=Se(t),{loading:i,trigger:o}=me(),c=i&&!n;return React.createElement(a.ReactNative.View,{style:{flexDirection:"row",flex:1}},React.createElement(a.ReactNative.View,{style:{paddingRight:6}},React.createElement(x.Button,{size:"small",text:"",style:[e?.style,{width:32},!!n&&{opacity:.5}],renderIcon:function(){return c?React.createElement(a.ReactNative.ActivityIndicator,{size:"small",color:"#fff"}):React.createElement(a.ReactNative.Image,{source:ye,style:{width:20,height:20,tintColor:"#fff"}})},onPress:function(){return!c&&(ve(n,t,r),!n&&o())}})),React.createElement(a.ReactNative.View,{style:{flexGrow:1}},React.createElement(x.Button,e)))}const q=s.findByProps("SpotifyPlayButton");var Ie=new S({id:"spotify-listen-along",label:"Add Listen Along",meta:{sublabel:"Ports the Spotify listen along feature from desktop to mobile in Spotify activities",category:f.Useful},handlers:{onStart(){q?.SpotifyPlayButton&&this.patches.add(v.after("SpotifyPlayButton",q,function([e],t){if(t)return a.React.createElement(Re,{button:t.props,activity:e?.activity})}))},onStop(){}}});const{View:we,TouchableOpacity:Ce,Image:$e}=a.ReactNative,Q=s.findByStoreName("SpotifyStore"),De=s.findByStoreName("SelectedChannelStore"),Ae=s.findByStoreName("DraftStore"),W=s.findByProps("sendMessage","revealMessage"),z=s.findByProps("clearDraft"),Ee=function(){if(!W?.sendMessage||!z?.clearDraft)return;const e=Q?.getActivity?.();if(!e?.party?.id)return;const t=De?.getChannelId?.();t&&(W.sendMessage(t,{content:Ae?.getDraft?.(t,0)??"",tts:!1,invalidEmojis:[],validNonShortcutEmojis:[]},!0,{activityAction:{activity:e,type:3}}),z.clearDraft(t,0))};function ke(){const[,e]=a.React.useReducer(function(r){return~r},0);a.React.useEffect(function(){return k("SPOTIFY_PLAYER_STATE",e)});const t=!!(W?.sendMessage&&z?.clearDraft&&Q?.getActivity?.()?.party?.id),n=y.getAssetByID(y.getAssetIDByName("ic_spotify_white_16px"));return a.React.createElement(we,{style:{opacity:t?1:.4,paddingHorizontal:8,justifyContent:"center"}},a.React.createElement(Ce,{disabled:!t,onPress:Ee},n?.uri?a.React.createElement($e,{source:{uri:n.uri},style:{width:22,height:22}}):a.React.createElement(a.ReactNative.Text,{style:{color:"#1ED760",fontWeight:"700"}},"\u266B")))}const X=s.findByTypeName("MediaKeyboardListHeader",!1);var Te=new S({id:"send-spotify-invite",label:"Send Spotify invite",meta:{sublabel:"Adds a button in the chat attachment menu to invite the channel to listen along to Spotify",category:f.Useful},handlers:{onStart(){X&&this.patches.add(v.after("type",X,function(e,t){if(!(!t?.props||!Array.isArray(t.props.children)))return{...t,props:{...t.props,children:[...t.props.children,a.React.createElement(ke,{})]}}}))},onStop(){}}});function Ne(e){const{NativeModules:t}=a.ReactNative,n=t?.DCDChatManager;if(n?.updateRows)return v.before("updateRows",n,function(i){try{const o=JSON.parse(i[1]);e(o),i[1]=JSON.stringify(o)}catch{}});const r=s.findByName("RowManager",!1);return r?.prototype?.generate?v.after("generate",r.prototype,function(i,o){try{e([o])}catch{}}):function(){}}const Z=s.findByStoreName("GuildMemberStore");var Le=new S({id:"minimod",label:"Minimod",meta:{sublabel:"Lets you see some moderator-only things, like whether a member is currently timed out",category:f.Fun},settings:{showTimeouts:{label:"Show timeouts",subLabel:"Show member timeout icons in chat",type:"toggle",default:!0}},handlers:{onStart(){!this.storage.options.showTimeouts||!Z?.getMember||this.patches.add(Ne(function(e){if(!e.some(function(n){return"message"in n}))return;const t=Date.now();for(const n of e){if(n.type!==1)continue;const r=Z.getMember(n.message.guildId,n.message.authorId)?.communicationDisabledUntil;r&&new Date(r).getTime()>t&&(n.message.communicationDisabled=!0)}}))},onStop(){}}});const Fe=s.findByStoreName("ThemeStore"),Be=s.find(function(e){return e?.default?.internal?.resolveSemanticColor})?.default?.internal?.resolveSemanticColor??s.find(function(e){return e?.meta?.resolveSemanticColor})?.meta?.resolveSemanticColor??function(){};function ee(e,t=Fe?.theme){if(e)try{return Be(t,e)}catch{return}}const{View:Pe,Text:_e}=a.ReactNative,te={destructive:{bg:"#F23F42",fg:"#FFFFFF"},default:{bg:"#4E5058",fg:"#FFFFFF"}};function xe({variant:e="default",children:t}){const n=te[e]??te.default;return a.React.createElement(Pe,{style:{backgroundColor:n.bg,borderRadius:4,paddingHorizontal:4,paddingVertical:1,marginLeft:4,alignSelf:"center"}},a.React.createElement(_e,{style:{color:n.fg,fontSize:10,fontWeight:"700",textTransform:"uppercase"}},t))}var Me="f47fd463dcaac61e.png",Ue="f944dbd033a60207.png",Oe="88eacd3588829ded.png",We="4d1aef97fe869aaf.png",ze="3a73d84a21043a5e.png",je="8b628d7e3fc05957.png",Ve="cb7a2c9b3fb9561c.png",Ge="11d89273b5bd6cc6.png",He="ea31146eb15fdde7.png",Ye="b0d124bd12658047.png",Je="cb8b45023e70bb61.png",Ke="a738efc867a225ee.png",qe="cba17334eeaf3198.png",Qe="fead9e69933db668.png",Xe="fead9e69933db668.png",Ze="d6a4e512cdcf1078.png",et="9901722947705011.png",tt=function(e){return e.Lock="Lock",e.Warning="Warning",e.Controller="Controller",e}(tt||{});function nt(e,t){if(e==="Lock")return t?He:Ge;if(e==="Warning")return t?et:Ze;if(e==="Controller")return Oe}const at={Lock:["#f0b232","STATUS_WARNING"],Warning:["#f23f43","STATUS_DANGER"],Controller:["#23a55a","STATUS_POSITIVE"]},rt=[{name:"Announcements",kind:"Lock",base:Me},{name:"Announcements",kind:"Warning",base:Ue},{name:"Text",kind:"Lock",base:Ke},{name:"Text",kind:"Warning",base:qe},{name:"Text",kind:"Controller",base:Je},{name:"Voice",kind:"Lock",base:Qe},{name:"Voice",kind:"Warning",base:Xe},{name:"Forum",kind:"Lock",base:We},{name:"Forum",kind:"Warning",base:ze},{name:"Stage",kind:"Lock",bottom:!0,base:Ye},{name:"Stage",kind:"Warning",bottom:!0,base:0},{name:"Image",kind:"Lock",bottom:!0,base:je},{name:"Image",kind:"Warning",bottom:!0,base:Ve}],ne=s.findByName("ChannelInfo",!1),ae=s.findByProps("BaseChannelIcon");var it=new S({id:"colorful-channels",label:"Colorful Channels",meta:{sublabel:"Gives channel icons with symbols colors to make them more aesthetically pleasing",category:f.Useful},settings:{nsfwTag:{label:"NSFW tag",subLabel:"Adds a red NSFW tag next to channel names",type:"toggle",default:!0},colorIcons:{label:"Colored icon symbols",subLabel:"Turns locked channel symbols yellow, NSFW channel symbols red",type:"toggle",default:!0},colorIconsFallback:{label:"Fallback colors for colored icon symbols",subLabel:"Uses yellow, red and green colors regardless of theme",type:"toggle",default:!1}},handlers:{onStart(){var e=this;this.storage.options.nsfwTag&&ne&&this.patches.add(v.after("default",ne,function([{channel:t}],n){return a.React.createElement(a.React.Fragment,{},t?.nsfw_&&a.React.createElement(xe,{variant:"destructive"},"nsfw"),n)})),this.storage.options.colorIcons&&ae?.BaseChannelIcon&&this.patches.add(v.after("BaseChannelIcon",ae,function([{source:t,style:n}],r){try{const i=typeof t?.original=="number"?y.getAssetByID(t.original)?.name:typeof t=="number"?y.getAssetByID(t)?.name:null;if(!i)return;const o=rt.find(function(P){return i===`${P.name}${P.kind}Icon`});if(!o)return;const[c,l]=at[o.kind],d=nt(o.kind,o.bottom),u=r?.props?.color?.replace(/-/g,"_")?.toUpperCase(),p=u&&M.semanticColors?.[u]?ee(M.semanticColors[u]):void 0,h=a.ReactNative.StyleSheet.flatten([n,r?.props?.style,{width:18,height:18,tintColor:p}]),B=e.storage.options.colorIconsFallback?c:ee(M.semanticColors?.[l])??c;return a.React.createElement(a.ReactNative.View,{},a.React.createElement(a.ReactNative.Image,{style:h,source:o.base}),a.React.createElement(a.ReactNative.View,{style:{position:"absolute",right:0,bottom:0}},a.React.createElement(a.ReactNative.Image,{style:{...h,tintColor:B},source:d})))}catch{return}}))},onStop(){}}});const j=s.findByProps("openLazy","hideActionSheet"),{ActionSheetRow:m}=s.findByProps("ActionSheetRow")??{},N=new Set;let I=null;function ot(e,t){return m?a.React.createElement(m,{label:e.label,subLabel:e.sublabel,icon:e.icon?a.React.createElement(m.Icon,{source:y.getAssetIDByName(e.icon)}):void 0,onPress:function(){try{e.onPress(t)}finally{j?.hideActionSheet?.()}},key:e.key}):null}function st(e){const t=[];for(const n of N)try{for(const r of n(e)){const i=ot(r,e);i&&t.push(i)}}catch{}return t}function lt(){return v.before("openLazy",j,function([e,t,n]){t!=="MessageLongPressActionSheet"||!n?.message||e.then(function(r){r.__roseUtilsActiveMessage=n.message,!r.__roseUtilsPatched&&(r.__roseUtilsPatched=!0,v.after("default",r,function(i,o){try{const c=st(r.__roseUtilsActiveMessage);if(!c.length)return;const l=U.findInReactTree(o,function(u){return Array.isArray(u)&&u[0]?.type?.name==="ActionSheetRowGroup"});if(Array.isArray(l)&&l.length&&m){let u=!1;for(const p of l){const h=U.findInReactTree(p,function(B){return Array.isArray(B)&&B.some(function(P){return P?.type?.name==="ActionSheetRow"})});if(Array.isArray(h)){h.push(...c),u=!0;break}}if(!u&&typeof l.unshift=="function"&&m.Group&&(l.unshift(a.React.createElement(m.Group,{},c)),u=!0),u)return}const d=U.findInReactTree(o,function(u){return Array.isArray(u)&&u.length>0&&u.every(function(p){return typeof p?.props?.label=="string"&&typeof p?.props?.onPress=="function"})});Array.isArray(d)&&d.push(...c)}catch{}}))})})}function b(e){return!I&&j&&(I=lt()),N.add(e),function(){N.delete(e),N.size===0&&I&&(I(),I=null)}}const ct=s.findByProps("DeveloperMode","DarkSidebar"),re=s.findByStoreName("PresenceStore");function ut(e){const t=e?.interaction??e?.interactionMetadata??e?.interaction_metadata;return t?.id?{id:String(t.id),name:t.name}:null}function dt(e){const t=ut(e);return t?[{key:"rose-utils-copy-command-id",label:"Copy Command ID",sublabel:t.name?`/${t.name}`:"Slash command interaction",icon:"ic_copy_24px",onPress:function(){a.clipboard.setString(t.id),g.showToast("Copied command ID to clipboard",y.getAssetIDByName("ic_copy_24px"))}}]:[]}function ft(e){if(!re?.getActivities)return[];const t=e?.author?.id;if(!t)return[];let n;try{n=re.getActivities(t)}catch{return[]}if(!Array.isArray(n))return[];const r=n.filter(function(i){return i?.application_id??i?.applicationId});return r.length?r.map(function(i,o){const c=String(i.application_id??i.applicationId);return{key:`rose-utils-copy-activity-id-${o}`,label:r.length>1?`Copy Activity ID (${i.name??o+1})`:"Copy Activity/Game ID",sublabel:i.name,icon:"ic_copy_24px",onPress:function(){a.clipboard.setString(c),g.showToast(`Copied ${i.name??"activity"} ID to clipboard`,y.getAssetIDByName("ic_copy_24px"))}}}):[]}var pt=new S({id:"enforce-developer-mode",label:"Developer Mode",meta:{sublabel:"Turns on Discord's real Developer Mode (all its native Copy ID options) and adds extra copy-ID tools slash commands and activities don't get natively",category:f.Useful},settings:{keepNativeOn:{label:"Keep native Developer Mode on",subLabel:"Re-asserts Discord's own Developer Mode setting - it tends to reset itself on Revenge-based clients",type:"toggle",default:!0},copyCommandId:{label:"Copy Command ID",subLabel:"Adds a row to the message long-press menu for messages sent via a slash command",type:"toggle",default:!0},copyActivityId:{label:"Copy Activity/Game ID",subLabel:"Adds a row to the message long-press menu to copy the author's current game/activity application ID (not every activity type has one, e.g. a plain custom status)",type:"toggle",default:!0}},handlers:{onStart(){if(this.storage.options.keepNativeOn){const e=ct?.DeveloperMode;if(e?.getSetting&&e?.updateSetting){const t=function(){try{e.getSetting()||e.updateSetting(!0)}catch{}};t(),this.patches.add(k("USER_SETTINGS_PROTO_UPDATE",t));const n=setInterval(t,5e3);this.patches.add(function(){return clearInterval(n)})}}this.storage.options.copyCommandId&&this.patches.add(b(dt)),this.storage.options.copyActivityId&&this.patches.add(b(ft))},onStop(){}}});const R="ic_copy_24px";function w(e,t){a.clipboard.setString(e),g.showToast(t,y.getAssetIDByName(R))}function gt(e){const t=e?.webhookId??e?.webhook_id;return t?[{key:"rose-utils-copy-webhook-id",label:"Copy Webhook ID",icon:R,onPress:function(){return w(String(t),"Copied webhook ID to clipboard")}}]:[]}function yt(e){const t=e?.nonce;return t?[{key:"rose-utils-copy-nonce",label:"Copy Nonce",icon:R,onPress:function(){return w(String(t),"Copied nonce to clipboard")}}]:[]}function ht(e){const t=e?.attachments;if(!Array.isArray(t)||!t.length)return[];const n=t.map(function(r){return r?.id}).filter(Boolean);return n.length?[{key:"rose-utils-copy-attachment-ids",label:n.length>1?`Copy Attachment IDs (${n.length})`:"Copy Attachment ID",icon:R,onPress:function(){return w(n.join(", "),`Copied ${n.length} attachment ID${n.length===1?"":"s"} to clipboard`)}}]:[]}function bt(e){const t=e?.messageReference??e?.message_reference,n=t?.messageId??t?.message_id;return n?[{key:"rose-utils-copy-referenced-id",label:"Copy Replied-to Message ID",icon:R,onPress:function(){return w(String(n),"Copied replied-to message ID to clipboard")}}]:[]}function vt(e){return e?.id?[{key:"rose-utils-copy-debug-info",label:"Copy Message Debug Info",sublabel:"Type, flags, and timestamps",icon:R,onPress:function(){const t={id:e.id,channelId:e.channelId??e.channel_id,type:e.type,flags:e.flags,timestamp:e.timestamp,editedTimestamp:e.editedTimestamp??e.edited_timestamp};w(JSON.stringify(t,null,2),"Copied message debug info to clipboard")}}]:[]}var St=new S({id:"message-dev-tools",label:"Message Dev Tools",meta:{sublabel:"Extra copy-ID rows in the message long-press menu, beyond what Discord's Developer Mode gives you natively",category:f.Useful},settings:{copyWebhookId:{label:"Copy Webhook ID",subLabel:"For messages sent by a webhook",type:"toggle",default:!0},copyNonce:{label:"Copy Nonce",subLabel:"The client-generated ID used to match an optimistic send to its real message",type:"toggle",default:!0},copyAttachmentIds:{label:"Copy Attachment ID(s)",type:"toggle",default:!0},copyReferencedId:{label:"Copy Replied-to Message ID",type:"toggle",default:!0},copyDebugInfo:{label:"Copy Message Debug Info",subLabel:"Type, flags, and creation/edit timestamps as JSON",type:"toggle",default:!0}},handlers:{onStart(){const e=this.storage.options;e.copyWebhookId&&this.patches.add(b(gt)),e.copyNonce&&this.patches.add(b(yt)),e.copyAttachmentIds&&this.patches.add(b(ht)),e.copyReferencedId&&this.patches.add(b(bt)),e.copyDebugInfo&&this.patches.add(b(vt))},onStop(){}}});const mt=1420070400000n;function ie(e){const t=e.trim();if(!/^\d{15,20}$/.test(t))return null;try{const n=(BigInt(t)>>22n)+mt;return new Date(Number(n))}catch{return null}}function Rt(e){return ie(e)?.toISOString()??null}var It=new S({id:"snowflake-tools",label:"Snowflake Tools",meta:{sublabel:"Decode any Discord ID's creation timestamp - useful after copying an ID with Developer Mode",category:f.Useful},settings:{decodeClipboard:{label:"Decode ID(s) in clipboard",subLabel:"Copy one or more Discord IDs first (one per line, or comma-separated), then tap this",type:"button",action(){a.clipboard.getString().then(function(e){const t=e.split(/[\s,]+/).map(function(i){return i.trim()}).filter(Boolean);if(!t.length){g.showToast("Clipboard is empty",void 0);return}const n=t.map(function(i){const o=Rt(i);return o?`${i} -> ${o}`:`${i} -> not a valid snowflake`}),r=n.join(`
|
|
`);a.clipboard.setString(r),g.showToast(`Decoded ${n.length} ID${n.length===1?"":"s"} - result copied`,y.getAssetIDByName("ic_copy_24px"))})}}},handlers:{onStart(){},onStop(){}}});const oe=s.findByStoreName("GuildStore"),se=s.findByStoreName("RelationshipStore"),le=s.findByStoreName("GuildMemberStore"),wt=s.findByStoreName("UserStore"),V="ic_copy_24px";function ce(e,t){a.clipboard.setString(e),g.showToast(t,y.getAssetIDByName(V))}function ue(e){return e?.guildId??e?.guild_id??null}function Ct(e){const t=ue(e);if(!t||!oe?.getGuild)return[];const n=oe.getGuild(t);return n?[{key:"rose-utils-copy-server-info",label:"Copy Server Info",sublabel:n.name,icon:V,onPress:function(){const r={id:t,name:n.name,ownerId:n.ownerId,createdAt:ie(t)?.toISOString(),boostTier:n.premiumTier,boostCount:n.premiumSubscriberCount,verificationLevel:n.verificationLevel,vanityURLCode:n.vanityURLCode,description:n.description,features:n.features};ce(JSON.stringify(r,null,2),"Copied server info to clipboard")}}]:[]}function $t(e){const t=ue(e);if(!t||!se?.getFriendIDs||!le?.getMember)return[];let n;try{n=se.getFriendIDs()}catch{return[]}return!Array.isArray(n)||!n.length?[]:[{key:"rose-utils-copy-friends-in-server",label:"Copy Friends In This Server",sublabel:"Only counts friends already loaded into this server's member list this session",icon:V,onPress:function(){const r=n.filter(function(i){try{return!!le.getMember(t,i)}catch{return!1}}).map(function(i){return wt?.getUser?.(i)?.username??i});ce(r.length?r.join(", "):"(none found - they may just not be loaded into the member list yet)",`Copied ${r.length} friend${r.length===1?"":"s"} in this server to clipboard`)}}]}var Dt=new S({id:"server-info-tools",label:"Server Info Tools",meta:{sublabel:"Adds Copy Server Info and Copy Friends In This Server rows to the message long-press menu",category:f.Useful},settings:{copyServerInfo:{label:"Copy Server Info",subLabel:"Boost tier, verification level, features, vanity URL, creation date, and more",type:"toggle",default:!0},copyFriendsInServer:{label:"Copy Friends In This Server",subLabel:"Cross-references your friends list against this server's cached member list",type:"toggle",default:!0}},handlers:{onStart(){const e=this.storage.options;e.copyServerInfo&&this.patches.add(b(Ct)),e.copyFriendsInServer&&this.patches.add(b($t))},onStop(){}}}),L=[Ie,Te,Le,it,pt,St,It,Dt];const{ScrollView:At,View:Et}=a.ReactNative;function kt({children:e}){return a.React.createElement(At,{style:{flex:1}},e,a.React.createElement(Et,{style:{height:24}}))}const{View:Tt,Text:Nt}=a.ReactNative;function de({children:e,style:t}){return a.React.createElement(Tt,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},t]},a.React.createElement(Nt,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{View:C,Text:$,TouchableOpacity:D}=a.ReactNative,{FormSection:Lt,FormSwitchRow:fe,FormRow:G,FormInput:Ft}=x.Forms;function Bt(e,t){return typeof e.subLabel=="function"?e.subLabel(t):e.subLabel}function Pt(e,t){if(!t)return!0;const n=t.toLowerCase();return e.label.toLowerCase().includes(n)||e.meta.sublabel.toLowerCase().includes(n)?!0:Object.values(e.settings).some(function(r){return r.label.toLowerCase().includes(n)?!0:(typeof r.subLabel=="string"?r.subLabel:void 0)?.toLowerCase().includes(n)??!1})}function F(e,t){for(const n of e)n.storage.enabled!==t&&n.toggle()}function _t({module:e,settingKey:t}){const n=e.settings[t];if(n.predicate&&!n.predicate.call(e))return null;const r=e.storage.options[t],i=Bt(n,r),o=!e.storage.enabled;return n.type==="toggle"?a.React.createElement(fe,{label:n.label,subLabel:i,value:!!r,disabled:o,onValueChange:function(c){e.storage.options[t]=c,e.restart()}}):n.type==="button"?a.React.createElement(G,{label:n.label,subLabel:i,disabled:o,onPress:function(){return n.action.call(e)}}):a.React.createElement(G,{label:n.label,subLabel:[i,r].filter(Boolean).join(" - "),disabled:o,onPress:function(){const c=n.choices.indexOf(r);e.storage.options[t]=n.choices[(c+1)%n.choices.length],e.restart()}})}function xt({module:e}){e.useRefresh();const t=Object.entries(e.errors);return a.React.createElement(Lt,{title:e.label},a.React.createElement(fe,{label:"Enabled",subLabel:e.meta.sublabel,value:!!e.storage.enabled,onValueChange:function(){return e.toggle()}}),e.storage.enabled&&Object.keys(e.settings).map(function(n){return a.React.createElement(_t,{key:n,module:e,settingKey:n})}),t.length>0&&a.React.createElement(G,{label:`${t.length} error${t.length===1?"":"s"} - tap to copy`,onPress:function(){const n=t.map(function([r,i]){return`[${e.label}] ${r}
|
|
${i}`}).join(`
|
|
|
|
`);a.clipboard.setString(n),g.showToast("Copied - paste this when reporting the issue",void 0)}}))}function Mt({category:e,mods:t,collapsed:n,onToggleCollapse:r}){const i=t.filter(function(o){return o.storage.enabled}).length;return a.React.createElement(C,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:20,paddingBottom:4}},a.React.createElement(D,{onPress:r,style:{flexDirection:"row",alignItems:"center",flexShrink:1}},a.React.createElement($,{style:{fontSize:12,fontWeight:"700",opacity:.6}},n?"\u25B8":"\u25BE"," ",e.toUpperCase()," \xB7 ",i,"/",t.length)),a.React.createElement(C,{style:{flexDirection:"row"}},a.React.createElement(D,{onPress:function(){return F(t,!0)}},a.React.createElement($,{style:{fontSize:12,fontWeight:"600",opacity:.6}},"All")),a.React.createElement(D,{onPress:function(){return F(t,!1)},style:{marginLeft:16}},a.React.createElement($,{style:{fontSize:12,fontWeight:"600",opacity:.6}},"None"))))}const Ut=[f.Useful,f.Fixes,f.Fun];function Ot(){for(const l of L)l.useRefresh();const[e,t]=a.React.useState(""),[n,r]=a.React.useState(new Set),i=e.trim().length>0,o=Ut.map(function(l){return{category:l,mods:L.filter(function(d){return d.meta.category===l&&Pt(d,e.trim())})}}).filter(function({mods:l}){return l.length>0}),c=o.flatMap(function({mods:l}){return l});return a.React.createElement(kt,null,a.React.createElement(de,null,"RoseUtils is a collection of small, independent utilities - toggle whichever ones you want. Fork of nexpid's NexxUtils, with fixes for lookups that broke on newer Discord versions. If a module shows an error below, tap it to copy the details for a bug report."),a.React.createElement(C,{style:{paddingHorizontal:16}},a.React.createElement(Ft,{title:"Search",placeholder:"Search modules and settings...",value:e,onChange:t,autoCorrect:!1,autoCapitalize:"none"})),a.React.createElement(C,{style:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:16,paddingTop:8}},a.React.createElement(D,{onPress:function(){return F(c,!0)}},a.React.createElement($,{style:{fontSize:13,fontWeight:"600",opacity:.75}},"Enable ",i?"matching":"all")),a.React.createElement(D,{onPress:function(){return F(c,!1)},style:{marginLeft:16}},a.React.createElement($,{style:{fontSize:13,fontWeight:"600",opacity:.75}},"Disable ",i?"matching":"all"))),c.length===0&&a.React.createElement(de,null,'No modules or settings match "',e.trim(),'".'),o.map(function({category:l,mods:d}){const u=!i&&n.has(l);return a.React.createElement(C,{key:l},a.React.createElement(Mt,{category:l,mods:d,collapsed:u,onToggleCollapse:function(){r(function(p){const h=new Set(p);return h.has(l)?h.delete(l):h.add(l),h})}}),!u&&d.map(function(p){return a.React.createElement(xt,{key:p.id,module:p})}))}))}var Wt={onLoad(){E.modules??={};for(const e of L)try{e.storage.enabled&&e.start()}catch(t){A.logger.error(`[RoseUtils] Failed to start "${e.label}" on load: ${t}`)}},onUnload(){for(const e of L)try{e.stop()}catch(t){A.logger.error(`[RoseUtils] Failed to stop "${e.label}" cleanly: ${t}`)}},settings:Ot};return _.default=Wt,Object.defineProperty(_,"__esModule",{value:!0}),_})({},vendetta,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.plugin,vendetta.ui.toasts,vendetta.ui.components,vendetta.ui.assets,vendetta.ui,vendetta.utils);
|