commit cd506c133e175380bb3d8689464864e6c39c2e76 Author: amsyarasyiq Date: Sun Feb 12 16:32:23 2023 +0000 deploy: c890562b98b0248c677b0265f8ef35c684a2e3ba diff --git a/404.md b/404.md new file mode 100644 index 0000000..fcdcee6 --- /dev/null +++ b/404.md @@ -0,0 +1,16 @@ +--- +permalink: /404.html +--- +> **Note:** You accessed a link that returned a 404, probably by clicking one of the plugin links. You're supposed to copy the link address and add it into Vendetta. + +# amsyarasyiq's [Vendetta](https://github.com/vendetta-mod/Vendetta) Plugins + +Currently available plugins: +- HideGiftButton +- NoIdle +- MoreConfirm + +# How to install? +Paste a plugin URL into the Plugins page of Vendetta, following a basic format of: + +https://amsyarasyiq.github.io/letup/`PLUGIN_NAME` diff --git a/HideGiftButton/index.js b/HideGiftButton/index.js new file mode 100644 index 0000000..98be8d3 --- /dev/null +++ b/HideGiftButton/index.js @@ -0,0 +1 @@ +(function(t,n,i){"use strict";let o;const e=i.findByDisplayName("ChatInput");var d={onLoad:()=>{n.logger.log("Starting HideGiftButton..."),o=e.defaultProps.hideGiftButton,e.defaultProps.hideGiftButton=!0},onUnload:()=>{n.logger.log("Unloading HideGiftButton.."),e.defaultProps.hideGiftButton=o}};return t.default=d,Object.defineProperty(t,"__esModule",{value:!0}),t})({},vendetta,vendetta.metro); diff --git a/Last.fm/index.js b/Last.fm/index.js new file mode 100644 index 0000000..7ef4055 --- /dev/null +++ b/Last.fm/index.js @@ -0,0 +1 @@ +(function(c,m,T,n,d,S,o,L,b){"use strict";const u={DEFAULT_APP_NAME:"Music",APPLICATION_ID:"1054951789318909972",LFM_API_KEY:"615322f0047e12aedbc610d9d71f7430",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"]};async function P(){const e=new URLSearchParams({method:"user.getrecenttracks",user:s.username,api_key:u.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),r=await fetch(`https://ws.audioscrobbler.com/2.0/?${e}`).then(i=>{if(!i.ok)throw new Error(`Failed to fetch latest scrobble: ${i.status} ${i.statusText}`);return i.json()}),t=r.recenttracks?.track?.[0]||Promise.reject(r);return{name:t.name,artist:t.artist.name,album:t.album["#text"],albumArt:R(t.image[3]["#text"]),url:t.url,date:t.date?.["#text"]??"now",nowPlaying:Boolean(t["@attr"]?.nowplaying),loved:t.loved==="1"}}function R(e){return u.LFM_DEFAULT_COVER_HASHES.some(r=>e.includes(r))?null:e}async function A(e){return a.stopped&&(console.log("--> Plugin is unloaded, aborting..."),a.updateInterval&&clearInterval(a.updateInterval),e=null),a.lastActivity=e,await _.handler({isSocketConnected:()=>!0,socket:{id:120,application:{id:u.APPLICATION_ID,name:e?.name||"RichPresence"},transport:"ipc"},args:{pid:120,activity:e&&{...e}||null}})}function g(){return a.lastActivity&&l("--> Clearing activity..."),A(null)}async function w(){if(l("--> Fetching last track..."),!s.username)throw b.showToast("Last.fm username is not set!",o.getAssetIDByName("Small")),await h(),new Error("Username is not set");const e=await P().catch(async function(i){throw l("--> An error occurred while fetching the last track, aborting..."),await g().catch(),i});if(!e.nowPlaying)return l("--> Last track is not currently playing, aborting..."),await g();if(l("--> Track fetched! Setting activity..."),a.lastTrackUrl===e.url){l("--> Last track is the same as the previous one, aborting...");return}const r={name:s.appName||u.DEFAULT_APP_NAME,type:s.listeningTo?2:0,details:e.name,state:`by ${e.artist}`};a.lastTrackUrl=e.url,s.showTimestamp&&(r.timestamps={start:Date.now()/1e3|0}),e.album&&(r.assets={large_image:e.albumArt,large_text:`on ${e.album}`});const t=await A(r).catch(async function(i){throw l("--> An error occurred while setting the activity"),await g().catch(),i});return l("--> Successfully set activity!"),l(t),t}function h(){return console.log("--> Flushing..."),a.lastActivity=null,a.updateInterval&&clearInterval(a.updateInterval),g()}async function y(){if(console.log("--> Initializing..."),a.stopped)throw new Error("Plugin is already stopped!");a.lastTrackUrl=null,a.updateInterval&&clearInterval(a.updateInterval),a.lastActivity&&await g();let e=0;w().catch(r=>{console.error(r),e++}),a.updateInterval=setInterval(()=>w().then(()=>e=0).catch(r=>{console.error(r),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),clearInterval(a.updateInterval),a.stopped=!0)}),s.timeInterval)}function F(){a.activityTypeUnpatch&&(console.warn("This is weird... activity type override is already defined?"),a.activityTypeUnpatch()),console.log("Patching activity type...");const e=Object.values(n.FluxDispatcher._actionHandlers._dependencyGraph.nodes),{actionHandler:r}=e.find(t=>t.name==="LocalActivityStore");return m.patcher.before("LOCAL_ACTIVITY_UPDATE",r,([{activity:t}])=>{t&&t.name===a.lastActivity.name&&(t.type=a.lastActivity.type)})}const{ScrollView:N,TouchableOpacity:U,Text:C}=n.ReactNative,{FormInput:E,FormDivider:p,FormSwitchRow:v,FormText:D,FormIcon:f}=L.Forms;function k(){const e=S.useProxy(d.storage),r=n.NavigationNative.useNavigation();return n.React.useEffect(()=>{r.setOptions({headerRight:()=>{async function t(){for(const i in d.storage)(typeof d.storage[i]=="boolean"||d.storage[i])&&(s[i]=e[i]);console.log("Applying settings..."),await h(),await y(),b.showToast("Settings updated!",o.getAssetIDByName("Check"))}return n.React.createElement(U,{onPress:t},n.React.createElement(D,{style:{marginRight:12}},"UPDATE"))}})},[]),n.React.createElement(N,null,n.React.createElement(E,{value:e.appName||void 0,onChangeText:t=>e.appName=t.trim(),title:"Discord Application Name",placeholder:u.DEFAULT_APP_NAME,returnKeyType:"done"}),n.React.createElement(p,null),n.React.createElement(E,{required:!0,value:e.username||void 0,onChangeText:t=>e.username=t.trim(),title:"Last.fm username",helpText:!e.username&&n.React.createElement(C,{style:{color:"#FF0000"}},"This field is required!"),placeholder:"wumpus123",returnKeyType:"done"}),n.React.createElement(p,null),n.React.createElement(v,{label:"Show time elapsed",subLabel:"Show the time elapsed since the song started playing",leading:n.React.createElement(f,{source:o.getAssetIDByName("clock")}),value:e.showTimestamp,onValueChange:t=>e.showTimestamp=t}),n.React.createElement(p,null),n.React.createElement(v,{label:"Set status as listening",subLabel:'Set your status as "Listening to" instead of "Playing"',leading:n.React.createElement(f,{source:o.getAssetIDByName("ic_headset_neutral")}),value:e.listeningTo,onValueChange:t=>e.listeningTo=t}),n.React.createElement(p,null),n.React.createElement(v,{label:"Verbose logging",subLabel:"Log more information to the console for debugging purposes",leading:n.React.createElement(f,{source:o.getAssetIDByName("icon-qs-files")}),value:e.verboseLogging,onValueChange:t=>e.verboseLogging=t}))}const a={},s={...m.plugin.storage},I=T.findByStoreName("UserStore"),_=T.findByProps("SET_ACTIVITY").SET_ACTIVITY,l=(...e)=>s.verboseLogging&&console.log(...e);var O={onLoad:()=>{console.log("Starting last.fm plugin.."),a.activityTypeUnpatch=F(),a.stopped=!1,I.getCurrentUser()&&(console.log("User is already logged in, initializing..."),y().catch(console.error)),n.FluxDispatcher.subscribe("CONNECTION_OPEN",()=>{y().catch(console.error)})},onUnload:()=>{console.log("Stopping last.fm..."),a.stopped=!0,h(),a.activityTypeUnpatch?.(),a.activityTypeUnpatch=null},settings:k};return c.SET_ACTIVITY=_,c.UserStore=I,c.currentSettings=s,c.default=O,c.global=a,c.verboseLog=l,Object.defineProperty(c,"__esModule",{value:!0}),c})({},vendetta,vendetta.metro,vendetta.metro.common,vendetta.plugin,vendetta.storage,vendetta.ui.assets,vendetta.ui.components,vendetta.ui.toasts); diff --git a/MoreConfirm/index.js b/MoreConfirm/index.js new file mode 100644 index 0000000..afb1af5 --- /dev/null +++ b/MoreConfirm/index.js @@ -0,0 +1 @@ +(function(r,o,t){"use strict";const i=t.findByProps("show","confirm","close"),s=t.findByProps("handleStartCall");var d={onLoad:()=>{o.logger.log("MoreConfirm: patching calls..."),o.patcher.instead("handleStartCall",s,(a,u)=>{const[{rawRecipients:[{username:n,discriminator:l},c]},f]=a,e=f?"video call":"call";i.show({title:c?`MoreConfirm: Start a group ${e}?`:`MoreConfirm: Start a ${e} with ${n}#${l}?`,body:c?"Are you sure you want to start the group call?":`Are you sure you want to ${e} ${n}#${l}?`,confirmText:"Yes",cancelText:"Cancel",confirmColor:"brand",onConfirm:()=>{try{u(...a)}catch(h){o.logger.error("Failed to start call",h)}}})})}};return r.default=d,Object.defineProperty(r,"__esModule",{value:!0}),r})({},vendetta,vendetta.metro); diff --git a/NoIdle/index.js b/NoIdle/index.js new file mode 100644 index 0000000..b877c06 --- /dev/null +++ b/NoIdle/index.js @@ -0,0 +1 @@ +(function(e,t,l){"use strict";let o;var r={onLoad:()=>{t.logger.log("Starting NoIdle..."),o=t.patcher.before("dispatch",l.FluxDispatcher,([{type:n}])=>{if(n==="IDLE")return[{type:"IDLE",idle:!1}]})},onUnload:()=>{t.logger.log("Disabling NoIdle.."),o?.()}};return e.default=r,Object.defineProperty(e,"__esModule",{value:!0}),e})({},vendetta,vendetta.metro.common); diff --git a/README.md b/README.md new file mode 100644 index 0000000..16fabc7 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# amsyarasyiq's [Vendetta](https://github.com/vendetta-mod/Vendetta) Plugins + +Currently available plugins: +- HideGiftButton +- NoIdle +- MoreConfirm + +# How to install? +Paste a plugin URL into the Plugins page of Vendetta, following a basic format of: + +https://amsyarasyiq.github.io/letup/`PLUGIN_NAME`