1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
(function(c,b,u,v,d,n,E){"use strict";const P={he:"he/him",she:"she/her",they:"they/them",it:"it/its",any:"any",other:"other",ask:"ask",avoid:"avoid, use name"};function $(e){if(e?.length)return e.map(function(t){return P[t]??t}).join(" / ")}const i=new Map,o=new Map;let l=new Set,f;function h(e,t){o.get(e)?.forEach(function(r){return r(t)}),o.delete(e)}async function T(){const e=[...l];if(l=new Set,!!e.length)try{const t=await(await d.safeFetch(`https://pronoundb.org/api/v2/lookup?platform=discord&ids=${e.join(",")}`,{headers:{Accept:"application/json"}})).json();for(const r of e){const a=$(t?.[r]?.sets?.en);i.set(r,a??null),h(r,a)}}catch{for(const t of e)i.set(t,null),h(t,void 0)}}function k(e){return i.get(e)??void 0}function S(e,t){return i.has(e)?(t(i.get(e)??void 0),function(){}):(o.has(e)||o.set(e,new Set),o.get(e).add(t),l.add(e),clearTimeout(f),f=setTimeout(T,150),function(){return o.get(e)?.delete(t)})}const{Text:I}=n.ReactNative,p=u.findByName("UserProfileSection",!1);function A({userId:e}){const[t,r]=n.React.useState(function(){return k(e)});return n.React.useEffect(function(){return S(e,r)},[e]),!t||!p?null:n.React.createElement(p,{title:"Pronouns"},n.React.createElement(I,{style:{fontSize:16}},t))}const{ScrollView:U,View:N}=n.ReactNative;function j({children:e}){return n.React.createElement(U,{style:{flex:1}},e,n.React.createElement(N,{style:{height:24}}))}const{View:C,Text:F}=n.ReactNative;function y({children:e,style:t}){return n.React.createElement(C,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},t]},n.React.createElement(F,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},e))}const{TouchableOpacity:H,Text:V}=n.ReactNative;function z({label:e,onPress:t,disabled:r,style:a}){return n.React.createElement(H,{disabled:r,onPress:t,style:[{backgroundColor:"#5865F2",borderRadius:8,padding:10,alignItems:"center",opacity:r?.5:1},a]},n.React.createElement(V,{style:{color:"white",fontWeight:"600"}},e))}const{View:B,Linking:D}=n.ReactNative,{FormSection:M}=E.Forms,m="https://pronoundb.org/";function x(){return n.React.createElement(j,null,n.React.createElement(M,{title:"How this works"},n.React.createElement(y,null,"This plugin doesn't have anything to configure here - there's no API key or toggle, because pronouns aren't Discord data. They come from PronounDB, a separate service where people manually set their own pronouns and link the profile to their Discord account."),n.React.createElement(y,null,"That means a user's pronouns will only show up if THEY set them at pronoundb.org - not because of anything you enable here. If you want your own pronouns to show up for other people running this plugin, set them yourself at the link below."),n.React.createElement(B,{style:{paddingHorizontal:16,paddingTop:4}},n.React.createElement(z,{label:"Open pronoundb.org",onPress:function(){return D.openURL(m)}}))))}const g=u.find(function(e){return e?.type?.name==="UserProfileContent"})??u.find(function(e){return e?.type?.name==="UserProfile"});function L(){return g?v.after("type",g,function(e,t){try{const r=d.findInReactTree(t,function(s){return Array.isArray(s?.props?.children)&&s.props.children.some(function(w){return w?.type?.name==="UserProfileAboutMeCard"||w?.type?.name==="UserProfileBio"})})?.props?.children;if(!Array.isArray(r))return;const a=r.find(function(s){return typeof s?.props?.displayProfile?.userId=="string"})?.props?.displayProfile?.userId;if(!a)return;r.unshift(React.createElement(A,{userId:a}))}catch{}}):function(){}}let R=function(){};var O={onLoad:function(){try{R=L()}catch(e){b.logger.error(`[PronounDB] Failed to apply the profile patch: ${e}`)}},onUnload:function(){return R()},settings:x};return c.default=O,Object.defineProperty(c,"__esModule",{value:!0}),c})({},vendetta,vendetta.metro,vendetta.patcher,vendetta.utils,vendetta.metro.common,vendetta.ui.components);
|