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

1 line
3.4 KiB
JavaScript

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