diff --git a/HideGiftButton/index.js b/HideGiftButton/index.js index c5268de..545adb8 100644 --- a/HideGiftButton/index.js +++ b/HideGiftButton/index.js @@ -1 +1 @@ -(function(a,f,r){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n Clearing activity..."),S(null)}function S(e){i.pluginStopped&&(console.log("--> Plugin is unloaded, aborting..."),i.updateInterval&&clearInterval(i.updateInterval),e=null),i.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e,pid:2312,socketId:"Last.fm@Vendetta"})}async function V(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:o.APPLICATION_ID;if(!e)return[];const t=L.getAssetIds(n,e);return t.length>0?t:await L.fetchAssetIds(n,e)}async function N(){if(l("--> Fetching last track..."),!s.username)throw _.showToast("Last.fm username is not set!",u.getAssetIDByName("Small")),h(),new Error("Username is not set");if(s.ignoreSpotify){for(const t of k.getActivities(A.getCurrentUser().id))if(t?.type===T.LISTENING&&t.application_id!==o.APPLICATION_ID){l("--> Spotify is currently playing, aborting..."),d();return}}const e=await O().catch(async function(t){throw l("--> An error occurred while fetching the last track, aborting..."),d(),t});if(!e.nowPlaying){l("--> Last track is not currently playing, aborting..."),d();return}if(l("--> Track fetched!"),i.lastTrackUrl===e.url){l("--> Last track is the same as the previous one, aborting...");return}const n={name:s.appName||o.DEFAULT_APP_NAME,flags:0,type:s.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,application_id:o.APPLICATION_ID};if(i.lastTrackUrl=e.url,n.name.includes("{{"))for(const t in e)n.name=n.name.replace(`{{${t}}}`,e[t]);s.showTimestamp&&(n.timestamps={start:Date.now()/1e3|0}),e.album&&(n.assets={large_image:(await V([e.albumArt]))[0],large_text:`on ${e.album}`}),l("--> Setting activity..."),l(n);try{S(n)}catch(t){throw l("--> An error occurred while setting the activity"),d(),t}l("--> Successfully set activity!")}function h(){console.log("--> Flushing..."),i.lastActivity=null,i.lastTrackUrl=null,i.updateInterval&&clearInterval(i.updateInterval),d()}async function E(){if(console.log("--> Initializing..."),i.pluginStopped)throw new Error("Plugin is already stopped!");h();let e=0;await N().catch(function(n){console.error(n),e++}),i.updateInterval=setInterval(function(){return N().then(function(){e=0}).catch(function(n){console.error(n),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),h())})},(Number(s.timeInterval)||o.DEFAULT_TIME_INTERVAL)*1e3)}const{FormInput:v,FormDivider:g,FormSwitchRow:p,FormText:B,FormIcon:m}=R.Forms;function x(){async function e(){for(const n in f.storage)(f.storage[n]===!1||f.storage[n])&&(s[n]=f.storage[n]);console.log("Applying settings..."),await E(),_.showToast("Settings updated!",u.getAssetIDByName("Check"))}return a.React.createElement(I.TouchableOpacity,{onPress:e},a.React.createElement(B,{style:{marginRight:12}},"UPDATE"))}function G(){const e=P.useProxy(f.storage),n=a.NavigationNative.useNavigation();return C.useEffect(function(){n.setOptions({title:"Last.fm Configuration",headerRight:x})},[]),a.React.createElement(I.ScrollView,null,a.React.createElement(v,{value:e.appName||void 0,onChangeText:function(t){return e.appName=t.trim()},title:"Discord Application Name",placeholder:o.DEFAULT_APP_NAME,returnKeyType:"done"}),a.React.createElement(g,null),a.React.createElement(v,{required:!0,value:e.username||void 0,onChangeText:function(t){return e.username=t.trim()},title:"Last.fm username",helpText:!e.username&&a.React.createElement(I.Text,{style:{color:"#FF0000"}},"This field is required!"),placeholder:"wumpus123",returnKeyType:"done"}),a.React.createElement(g,null),a.React.createElement(v,{value:e.timeInterval,onChangeText:function(t){return e.timeInterval=t},title:"Update interval (in seconds)",placeholder:o.DEFAULT_TIME_INTERVAL.toString(),keyboardType:"numeric",returnKeyType:"done"}),a.React.createElement(g,null),a.React.createElement(p,{label:"Show time elapsed",subLabel:"Show the time elapsed since the song started playing",leading:a.React.createElement(m,{source:u.getAssetIDByName("clock")}),value:e.showTimestamp,onValueChange:function(t){return e.showTimestamp=t}}),a.React.createElement(g,null),a.React.createElement(p,{label:"Set status as listening",subLabel:'Set your status as "Listening to" instead of "Playing"',leading:a.React.createElement(m,{source:u.getAssetIDByName("ic_headset_neutral")}),value:e.listeningTo,onValueChange:function(t){return e.listeningTo=t}}),a.React.createElement(g,null),a.React.createElement(p,{label:"Hide when Spotify is running",subLabel:"Hide the status when a Spotify activity is detected",leading:a.React.createElement(m,{source:u.getAssetIDByName("img_account_sync_spotify_light_and_dark")}),value:e.ignoreSpotify,onValueChange:function(t){return e.ignoreSpotify=t}}),a.React.createElement(g,null),a.React.createElement(p,{label:"Verbose logging",subLabel:"Log more information to the console for debugging purposes",leading:a.React.createElement(m,{source:u.getAssetIDByName("pencil")}),value:e.verboseLogging,onValueChange:function(t){return e.verboseLogging=t}}))}const i={};b.plugin.storage.ignoreSpotify??=!0;const s={...b.plugin.storage},A=y.findByStoreName("UserStore"),{SET_ACTIVITY:Y}=y.findByProps("SET_ACTIVITY"),l=function(){for(var e=arguments.length,n=new Array(e),t=0;t1&&arguments[1]!==void 0?arguments[1]:u.APPLICATION_ID;return e?await C.fetchAssetIds(t,e):[]}let N;const R={};function c(e,t){R[e]=t,N?.()}function O(){return[,N]=h.useReducer(function(e){return~e},0),JSON.stringify(R,null,4)}async function V(){const e=new URLSearchParams({method:"user.getrecenttracks",user:s.username,api_key:u.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),t=await fetch(`https://ws.audioscrobbler.com/2.0/?${e}`);if(!t.ok)throw new Error(`Failed to fetch the latest scrobble: ${t.statusText}`);const n=await t.json(),l=n?.recenttracks?.track?.[0];if(c("lastAPIResponse",l),!l)throw n;return{name:l.name,artist:l.artist.name,album:l.album["#text"],albumArt:await x(l.image?.find(function(K){return K.size==="large"})?.["#text"]),url:l.url,date:l.date?.["#text"]??"now",nowPlaying:!!l["@attr"]?.nowplaying,loved:l.loved==="1"}}async function x(e){return u.LFM_DEFAULT_COVER_HASHES.some(function(t){return e.includes(t)})?null:e}var E;(function(e){e[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING"})(E||(E={}));const i=function(){for(var e=arguments.length,t=new Array(e),n=0;n Plugin is unloaded, aborting update()..."),g();return}if(i("--> Fetching last track..."),!s.username)throw _.showToast("Last.fm username is not set!",o.getAssetIDByName("Small")),g(),new Error("Username is not set");if(s.ignoreSpotify)if(k.findActivity(function(n){return n.sync_id})){i("--> Spotify is currently playing, aborting..."),c("isSpotifyIgnored",!0),p();return}else c("isSpotifyIgnored",!1);else c("isSpotifyIgnored",void 0);const e=await V().catch(async function(n){throw i("--> An error occurred while fetching the last track, aborting..."),p(),n});if(c("lastTrack",e),!e.nowPlaying){i("--> Last track is not currently playing, aborting..."),p();return}if(i("--> Track fetched!"),r.lastTrackUrl===e.url){i("--> Last track is the same as the previous one, aborting...");return}const t={name:s.appName||u.DEFAULT_APP_NAME,flags:0,type:s.listeningTo?E.LISTENING:E.PLAYING,details:e.name,state:`by ${e.artist}`,application_id:u.APPLICATION_ID};if(r.lastTrackUrl=e.url,t.name.includes("{{"))for(const n in e)t.name=t.name.replace(`{{${n}}}`,e[n]);if(s.showTimestamp&&(t.timestamps={start:Date.now()/1e3|0}),e.album){const n=await M([e.albumArt]);t.assets={large_image:n[0],large_text:`on ${e.album}`}}i("--> Setting activity..."),c("lastActivity",t),i(t);try{L(t)}catch(n){throw i("--> An error occurred while setting the activity"),p(),n}i("--> Successfully set activity!")}function g(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;r.lastActivity=null,r.lastTrackUrl=null,r.updateInterval&&clearInterval(r.updateInterval),!e&&p()}async function I(){if(r.pluginStopped)throw new Error("Plugin is already stopped!");g();let e=0;await P().catch(function(t){console.error(t),e++}),r.updateInterval=setInterval(function(){return P().then(function(){e=0}).catch(function(t){console.error(t),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),g())})},(Number(s.timeInterval)||u.DEFAULT_TIME_INTERVAL)*1e3)}const r={};w.plugin.storage.ignoreSpotify??=!0;const s={...w.plugin.storage};var B={settings:h.lazy(function(){return Promise.resolve().then(function(){return z})}),onLoad(){if(r.pluginStopped=!1,U.getCurrentUser())I().catch(console.error);else{const e=function(){I().catch(console.error),a.FluxDispatcher.unsubscribe(e)};a.FluxDispatcher.subscribe("CONNECTION_OPEN",e)}},onUnload(){r.pluginStopped=!0,g()}};const{FormRow:D,FormInput:T,FormDivider:d,FormSwitchRow:v,FormText:G,FormIcon:b}=S.Forms;function $(){async function e(){for(const t in y.storage)y.storage[t]!=null&&(s[t]=y.storage[t]);await I(),_.showToast("Settings updated!",o.getAssetIDByName("Check"))}return a.React.createElement(m.TouchableOpacity,{onPress:e},a.React.createElement(G,{style:{marginRight:12}},"UPDATE"))}var Y=a.React.memo(function(){const e=F.useProxy(y.storage),t=a.NavigationNative.useNavigation();return h.useEffect(function(){t.setOptions({title:"Last.fm Configuration",headerRight:$})},[]),a.React.createElement(m.ScrollView,null,a.React.createElement(T,{value:e.appName||void 0,onChangeText:function(n){return e.appName=n.trim()},title:"Discord Application Name",placeholder:u.DEFAULT_APP_NAME,returnKeyType:"done"}),a.React.createElement(d,null),a.React.createElement(T,{required:!0,value:e.username||void 0,onChangeText:function(n){return e.username=n.trim()},title:"Last.fm username",helpText:!e.username&&a.React.createElement(m.Text,{style:{color:"#FF0000"}},"This field is required!"),placeholder:"wumpus123",returnKeyType:"done"}),a.React.createElement(d,null),a.React.createElement(T,{value:e.timeInterval,onChangeText:function(n){return e.timeInterval=n},title:"Update interval (in seconds)",placeholder:u.DEFAULT_TIME_INTERVAL.toString(),keyboardType:"numeric",returnKeyType:"done"}),a.React.createElement(d,null),a.React.createElement(v,{label:"Show time elapsed",subLabel:"Show the time elapsed since the song started playing",leading:a.React.createElement(b,{source:o.getAssetIDByName("clock")}),value:e.showTimestamp,onValueChange:function(n){return e.showTimestamp=n}}),a.React.createElement(d,null),a.React.createElement(v,{label:"Set status as listening",subLabel:'Set your status as "Listening to" instead of "Playing"',leading:a.React.createElement(b,{source:o.getAssetIDByName("ic_headset_neutral")}),value:e.listeningTo,onValueChange:function(n){return e.listeningTo=n}}),a.React.createElement(d,null),a.React.createElement(v,{label:"Hide when Spotify is running",subLabel:"Hide the status when a Spotify activity is detected",leading:a.React.createElement(b,{source:o.getAssetIDByName("img_account_sync_spotify_light_and_dark")}),value:e.ignoreSpotify,onValueChange:function(n){return e.ignoreSpotify=n}}),a.React.createElement(d,null),a.React.createElement(D,{label:"Debug",subLabel:"View debug information",leading:a.React.createElement(b,{source:o.getAssetIDByName("debug")}),trailing:D.Arrow,onPress:function(){t.push("VendettaCustomPage",{title:"Debug",render:h.lazy(function(){return Promise.resolve().then(function(){return j})})})}}))}),z=Object.freeze({__proto__:null,default:Y});function H(){const e=O();return React.createElement(m.ScrollView,null,React.createElement(S.Codeblock,{selectable:!0,style:{margin:12}},e))}var j=Object.freeze({__proto__:null,default:H});return f.currentSettings=s,f.default=B,f.pluginState=r,Object.defineProperty(f,"__esModule",{value:!0}),f})({},vendetta.metro.common,vendetta.plugin,vendetta.storage,vendetta.ui.assets,vendetta.ui.components,vendetta.ui.toasts,window.React,vendetta.metro.common.ReactNative,vendetta,vendetta.metro); diff --git a/Last.fm/manifest.json b/Last.fm/manifest.json index 9606664..e4bee1e 100644 --- a/Last.fm/manifest.json +++ b/Last.fm/manifest.json @@ -1 +1 @@ -{"authors":[{"name":"pylix","id":"492949202121261067"}],"main":"index.js","name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","vendetta":{"icon":"ic_stage_music"},"hash":"0275abf3ddb12fa47986b16e887c062e18232b91c5c2d8ac4c7efbee1f165d1b"} \ No newline at end of file +{"authors":[{"name":"pylix","id":"492949202121261067"}],"main":"index.js","name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","vendetta":{"icon":"ic_stage_music"},"hash":"d29cfa07eba14d6d0ad1f22d1c074dd0ed17043e26549322e0d4754967efa3c6"} \ No newline at end of file diff --git a/NoAutoReplyMention/index.js b/NoAutoReplyMention/index.js deleted file mode 100644 index b16b3cc..0000000 --- a/NoAutoReplyMention/index.js +++ /dev/null @@ -1 +0,0 @@ -(function(s,b,g,m,e,v,u,w,f,i){"use strict";function x(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function p(n,a,r){return a in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r,n}const R=g.findByStoreName("UserStore"),{FormInput:F,FormDivider:h,FormText:I,FormIcon:o,FormRow:E,FormSection:_,FormSwitchRow:B}=w.Forms,y=e.stylesheet.createThemedStyleSheet({avatar:{height:36,width:36,borderRadius:18},button:{marginRight:12}});function S(n){let{callback:a}=n;return e.React.createElement(i.TouchableOpacity,{onPress:a},e.React.createElement(I,{style:y.button},"ADD"))}function T(n){let{onFinish:a}=n;const[r,l]=f.useState(""),d=function(){!isNaN(parseInt(r))&&R.getUser(r)&&!t.exempted.includes(r)&&(t.exempted=[...t.exempted,r],l("")),a()};return e.React.createElement(E,{leading:e.React.createElement(o,{source:u.getAssetIDByName("ic_add_friend")}),label:e.React.createElement(F,{autoFocus:!0,title:"User ID",placeholder:"123456789012345678",value:r,keyboardType:"numeric",onChangeText:function(c){return l(c.replace(/[^0-9]/g,"").trim())},returnKeyType:"done"}),trailing:e.React.createElement(i.TouchableOpacity,{onPress:d},e.React.createElement(o,{source:u.getAssetIDByName("ic_add_24px")}))})}function k(){v.useProxy(t);const[n,a]=f.useState(!1),r=e.NavigationNative.useNavigation();return f.useEffect(function(){r.setOptions({headerRight:function(){return e.React.createElement(S,{callback:function(){return a(!0)}})}})},[]),e.React.createElement(i.ScrollView,null,e.React.createElement(B,{label:"Enable blacklist mode",subLabel:"If enabled, only users in the exempted list will be affected by the plugin.",leading:e.React.createElement(o,{source:u.getAssetIDByName("ic_block")}),value:t.isBlacklistMode,onValueChange:function(l){return t.isBlacklistMode=l}}),e.React.createElement(_,{title:"Exempted Users"},t.exempted?.length>0&&e.React.createElement(i.FlatList,{data:t.exempted,keyExtractor:function(l){return l},renderItem:function(l){let{item:d}=l;const c=R.getUser(d);if(!c)throw new Error("User not found/is not cached");return e.React.createElement(E,{label:c.username,leading:e.React.createElement(i.Image,{style:y.avatar,source:{uri:c.getAvatarURL()}}),trailing:e.React.createElement(i.TouchableOpacity,{onPress:function(){t.exempted=t.exempted.filter(function(D){return D!==d})}},e.React.createElement(o,{source:u.getAssetIDByName("Small"),disableColor:!0}))})},ItemSeparatorComponent:h}),n&&e.React.createElement(e.React.Fragment,null,e.React.createElement(h,null),e.React.createElement(T,{onFinish:function(){return a(!1)}}))))}const t=m.storage,P=g.findByProps("createPendingReply");t.isBlacklistMode??=!1,t.exempted??=[];var U=new function n(){x(this,n),p(this,"settings",k),p(this,"onUnload",b.patcher.before("createPendingReply",P,function(a){let[r]=a;const l=t.exempted.includes(r.message?.author?.id);r.shouldMention&&=t.isBlacklistMode?!l:l}))};return s.default=U,s.settings=t,Object.defineProperty(s,"__esModule",{value:!0}),s})({},vendetta,vendetta.metro,vendetta.plugin,vendetta.metro.common,vendetta.storage,vendetta.ui.assets,vendetta.ui.components,window.React,vendetta.metro.common.ReactNative); diff --git a/NoAutoReplyMention/manifest.json b/NoAutoReplyMention/manifest.json deleted file mode 100644 index 7e85734..0000000 --- a/NoAutoReplyMention/manifest.json +++ /dev/null @@ -1 +0,0 @@ -{"authors":[{"name":"pylix","id":"492949202121261067"}],"main":"index.js","name":"NoAutoReplyMention","description":"Turns off auto mention when replying to someone.","vendetta":{"icon":"ic_notif_off"},"hash":"4ca2dc122f625dd6de9e08cf77fa382b54b8f7b4f6771d2db6a9d928319ad1e0"} \ No newline at end of file diff --git a/NoIdle/index.js b/NoIdle/index.js index df6550f..42e512e 100644 --- a/NoIdle/index.js +++ b/NoIdle/index.js @@ -1 +1 @@ -(function(t,u,o){"use strict";function c(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function f(e,n){for(var l=0;l