revenge-plugins/you-bar-plus/install/index.js
2026-08-02 00:17:23 +00:00

1 line
3.6 KiB
JavaScript

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