revenge-plugins/you-bar-plus/install/index.js
2026-08-01 20:04:30 +00:00

1 line
3.5 KiB
JavaScript

(function(d,B,i,p,n,R,y,b,S){"use strict";function E(t,e,r,a){try{return r()}catch(o){return a.error(`[${t}] Failed to apply the "${e}" patch, that surface will be skipped: ${o}`),function(){}}}function P(t,e,r){const a=Object.entries(r).map(function([o,u]){return E(t,o,u,e)});return function(){return a.forEach(function(o){return o()})}}function F(t,e,r=100){let a=!1,o;const u=t();return u?(e(u),{cancel(){}}):(o=setInterval(function(){if(a)return;const c=t();c&&(a=!0,clearInterval(o),e(c))},r),{cancel(){a=!0,o&&clearInterval(o)}})}const h=new Map;function I(){const t=window?.modules;if(t)for(const e in t){const r=Number(e);if(!h.has(r))try{const a=window.__r(r);a&&h.set(r,a)}catch{}}}function N(t){I();for(const e of h.values())try{if(t(e))return e;if(e?.default!=null&&t(e.default))return e.default}catch{}}function D(t){return N(function(e){return e?.name===t||e?.displayName===t||e?.type?.name===t||e?.type?.displayName===t})}let l=function(){};function M(){let t=function(){};const e=F(function(){return D("YouBarNotificationsButton")},function(r){t=V(r)});return function(){e.cancel(),t()}}function V(t){const e=p.findByProps("openUserSettings"),r=p.findByProps("transitionToGuild"),a=y.getAssetIDByName("ChatIcon"),o=y.getAssetIDByName("SettingsIcon");return R.instead("type",t,function(u,c){try{const[,A]=n.React.useReducer(function(L){return~L},0);l=function(){return A()};const s=c(...u);if(!s?.props?.children)return s;const v=s.props.children.type,f=s.props.children.props;return n.React.createElement(n.React.Fragment,null,i.storage.showDMButton&&n.React.createElement(v,{variant:f?.variant||"tertiary",size:f?.size||"sm",icon:a,onPress:function(){return r?.transitionToGuild?.("@me")}}),i.storage.showSettingsButton&&n.React.createElement(v,{variant:f?.variant||"tertiary",size:f?.size||"sm",icon:o,onPress:function(){return e?.openUserSettings?.()}}),s)}catch{return c(...u)}})}const{ScrollView:Y,View:m}=n.ReactNative;function z({children:t}){return n.React.createElement(Y,{style:{flex:1}},t,n.React.createElement(m,{style:{height:24}}))}const{View:$,Text:C}=n.ReactNative;function T({children:t,style:e}){return n.React.createElement($,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},e]},n.React.createElement(C,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},t))}const{FormSection:_,FormSwitchRow:g}=S.Forms;function k(){return b.useProxy(i.storage),n.React.useEffect(function(){return function(){return l()}},[]),n.React.createElement(z,null,n.React.createElement(T,null,"Fork of Purple-EyeZ's YouBar+, ported to Revenge's Vendetta-compat API with a fix for a startup race that could silently skip the button patch for an entire session."),n.React.createElement(_,{title:"Buttons"},n.React.createElement(g,{label:"Direct Messages button",subLabel:"Show the DM button in the YouBar",value:!!i.storage.showDMButton,onValueChange:function(t){i.storage.showDMButton=t,l()}}),n.React.createElement(g,{label:"Settings button",subLabel:"Show the Settings button in the YouBar",value:!!i.storage.showSettingsButton,onValueChange:function(t){i.storage.showSettingsButton=t,l()}})))}let w=function(){};var x={onLoad:function(){i.storage.showDMButton??=!1,i.storage.showSettingsButton??=!0,w=P("YouBar+",B.logger,{"YouBar buttons":M})},onUnload:function(){return w()},settings:k};return d.default=x,Object.defineProperty(d,"__esModule",{value:!0}),d})({},vendetta,vendetta.plugin,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.ui.assets,vendetta.storage,vendetta.ui.components);