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