diff --git a/HideGiftButton/index.js b/HideGiftButton/index.js index 47779b7..5751041 100644 --- a/HideGiftButton/index.js +++ b/HideGiftButton/index.js @@ -1 +1 @@ -!function(t,n,o){"use strict";let e;let i=o.findByDisplayName("ChatInput"),a=function(){function t(){!function(t,n){if(!(t instanceof n))throw TypeError("Cannot call a class as a function")}(this,t)}var o=t.prototype;return o.onLoad=function(){n.logger.log("Starting HideGiftButton..."),e=i.defaultProps.hideGiftButton,i.defaultProps.hideGiftButton=!0},o.onUnload=function(){n.logger.log("Unloading HideGiftButton.."),i.defaultProps.hideGiftButton=e},t}();t.default=a,Object.defineProperty(t,"__esModule",{value:!0})}({},vendetta,vendetta.metro); \ No newline at end of file +(function(exports,_vendetta,metro){'use strict';function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}let origState;const ChatInput=metro.findByDisplayName("ChatInput");var index = new(function(){function HideGiftButton(){_classCallCheck(this,HideGiftButton);}var _proto=HideGiftButton.prototype;_proto.onLoad=function onLoad(){_vendetta.logger.log("Starting HideGiftButton...");origState=ChatInput.defaultProps.hideGiftButton;ChatInput.defaultProps.hideGiftButton=true;};_proto.onUnload=function onUnload(){_vendetta.logger.log("Unloading HideGiftButton..");ChatInput.defaultProps.hideGiftButton=origState;};return HideGiftButton}());exports.default=index;Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},vendetta,vendetta.metro); \ No newline at end of file diff --git a/HideGiftButton/manifest.json b/HideGiftButton/manifest.json index d291160..3a2d030 100644 --- a/HideGiftButton/manifest.json +++ b/HideGiftButton/manifest.json @@ -1 +1 @@ -{"name":"HideGiftButton","description":"Hides the gift button in the chat input.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"ic_gift_24px"},"hash":"dc67a237c1d3b7742a0fb004f5783ce77538d638c6fb3582f2df7bd5d83e2af5"} \ No newline at end of file +{"name":"HideGiftButton","description":"Hides the gift button in the chat input.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"ic_gift_24px"},"hash":"9b9fc17e867866e0674424d44c542243771214fc72585b4819d50a24c92e2289"} \ No newline at end of file diff --git a/Last.fm/index.js b/Last.fm/index.js index 286a931..7f0feb5 100644 --- a/Last.fm/index.js +++ b/Last.fm/index.js @@ -1 +1,2 @@ -!function(e,t,n,a,r,o,i,l,s){"use strict";let c={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",LFM_API_KEY:"615322f0047e12aedbc610d9d71f7430",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"]},u=n.findByProps("getAssetIds");async function g(){let e=new URLSearchParams({method:"user.getrecenttracks",user:S.username,api_key:c.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),t=await fetch(`https://ws.audioscrobbler.com/2.0/?${e}`);if(!t.ok)throw Error(`Failed to fetch the latest scrobble: ${t.statusText}`);let n=await t.json(),a=n?.recenttracks?.track?.[0];if(!a)throw n;return{name:a.name,artist:a.artist.name,album:a.album["#text"],albumArt:await m(a.image[3]["#text"]),url:a.url,date:a.date?.["#text"]??"now",nowPlaying:Boolean(a["@attr"]?.nowplaying),loved:"1"===a.loved}}async function m(e){return c.LFM_DEFAULT_COVER_HASHES.some(function(t){return e.includes(t)})?null:e}function d(){return R.lastActivity&&F("--> Clearing activity..."),f(null)}function f(e){R.pluginStopped&&(console.log("--> Plugin is unloaded, aborting..."),R.updateInterval&&clearInterval(R.updateInterval),e=null),R.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e})}async function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.APPLICATION_ID;if(!e)return null;if("string"==typeof e){let n=await u.getAssetIds(t,[e]);return n[0]}return await u.getAssetIds(t,e)}async function h(){if(F("--> Fetching last track..."),!S.username)throw s.showToast("Last.fm username is not set!",i.getAssetIDByName("Small")),y(),Error("Username is not set");let e=await g().catch(async function(e){throw F("--> An error occurred while fetching the last track, aborting..."),d(),e});if(!e.nowPlaying){F("--> Last track is not currently playing, aborting..."),d();return}if(F("--> Track fetched!"),R.lastTrackUrl===e.url){F("--> Last track is the same as the previous one, aborting...");return}let t={name:S.appName||c.DEFAULT_APP_NAME,flags:0,type:S.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,application_id:c.APPLICATION_ID};if(R.lastTrackUrl=e.url,t.name.includes("{{"))for(let n in e)t.name=t.name.replace(`{{${n}}}`,e[n]);S.showTimestamp&&(t.timestamps={start:Date.now()/1e3|0}),e.album&&(t.assets={large_image:await p(e.albumArt),large_text:`on ${e.album}`}),F("--> Setting activity..."),F(t);try{f(t)}catch(e){throw F("--> An error occurred while setting the activity"),d(),e}F("--> Successfully set activity!")}function y(){console.log("--> Flushing..."),R.lastActivity=null,R.lastTrackUrl=null,R.updateInterval&&clearInterval(R.updateInterval),d()}async function T(){if(console.log("--> Initializing..."),R.pluginStopped)throw Error("Plugin is already stopped!");y();let e=0;await h().catch(function(t){console.error(t),e++}),R.updateInterval=setInterval(function(){return h().then(function(){e=0}).catch(function(t){console.error(t),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),y())})},1e3*(S.timeInterval||c.DEFAULT_TIME_INTERVAL))}let{ScrollView:E,TouchableOpacity:v,Text:A}=a.ReactNative,{FormInput:I,FormDivider:b,FormSwitchRow:_,FormText:L,FormIcon:w}=l.Forms;function N(){async function e(){for(let e in r.storage)(!1===r.storage[e]||r.storage[e])&&(S[e]=r.storage[e]);console.log("Applying settings..."),await T(),s.showToast("Settings updated!",i.getAssetIDByName("Check"))}return a.React.createElement(v,{onPress:e},a.React.createElement(L,{style:{marginRight:12}},"UPDATE"))}function P(){let e=o.useProxy(r.storage),t=a.NavigationNative.useNavigation();return a.React.useEffect(function(){t.setOptions({title:"Last.fm Configuration",headerRight:N})},[]),a.React.createElement(E,null,a.React.createElement(I,{value:e.appName||void 0,onChangeText:function(t){return e.appName=t.trim()},title:"Discord Application Name",placeholder:c.DEFAULT_APP_NAME,returnKeyType:"done"}),a.React.createElement(b,null),a.React.createElement(I,{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(A,{style:{color:"#FF0000"}},"This field is required!"),placeholder:"wumpus123",returnKeyType:"done"}),a.React.createElement(b,null),a.React.createElement(I,{value:e.timeInterval,onChangeText:function(t){return e.timeInterval=Number(t)},title:"Update interval (in seconds)",placeholder:c.DEFAULT_TIME_INTERVAL.toString(),keyboardType:"numeric",returnKeyType:"done"}),a.React.createElement(b,null),a.React.createElement(_,{label:"Show time elapsed",subLabel:"Show the time elapsed since the song started playing",leading:a.React.createElement(w,{source:i.getAssetIDByName("clock")}),value:e.showTimestamp,onValueChange:function(t){return e.showTimestamp=t}}),a.React.createElement(b,null),a.React.createElement(_,{label:"Set status as listening",subLabel:'Set your status as "Listening to" instead of "Playing"',leading:a.React.createElement(w,{source:i.getAssetIDByName("ic_headset_neutral")}),value:e.listeningTo,onValueChange:function(t){return e.listeningTo=t}}),a.React.createElement(b,null),a.React.createElement(_,{label:"Verbose logging",subLabel:"Log more information to the console for debugging purposes",leading:a.React.createElement(w,{source:i.getAssetIDByName("pencil")}),value:e.verboseLogging,onValueChange:function(t){return e.verboseLogging=t}}))}let R={},S={...t.plugin.storage},C=n.findByStoreName("UserStore"),D=n.findByProps("SET_ACTIVITY").SET_ACTIVITY,F=function(){for(var e=arguments.length,t=Array(e),n=0;n Clearing activity...");return sendRequest(null)}function sendRequest(activity){if(global.pluginStopped){console.log("--> Plugin is unloaded, aborting...");global.updateInterval&&clearInterval(global.updateInterval);activity=null;}global.lastActivity=activity;common.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:activity});}async function fetchAsset(asset){let appId=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Constants.APPLICATION_ID;if(!asset)return null;if(typeof asset==="string"){const assetId=await AssetManager.getAssetIds(appId,[asset]);return assetId[0]}return await AssetManager.getAssetIds(appId,asset)}async function update(){verboseLog("--> Fetching last track...");if(!currentSettings.username){toasts.showToast("Last.fm username is not set!",assets.getAssetIDByName("Small"));flush();throw new Error("Username is not set")}const lastTrack=await fetchLatestScrobble().catch(async function(err){verboseLog("--> An error occurred while fetching the last track, aborting...");clearActivity();throw err});if(!lastTrack.nowPlaying){verboseLog("--> Last track is not currently playing, aborting...");clearActivity();return}verboseLog("--> Track fetched!");if(global.lastTrackUrl===lastTrack.url){verboseLog("--> Last track is the same as the previous one, aborting...");return}const activity={name:currentSettings.appName||Constants.DEFAULT_APP_NAME,flags:0,type:currentSettings.listeningTo?2:0,details:lastTrack.name,state:`by ${lastTrack.artist}`,application_id:Constants.APPLICATION_ID};global.lastTrackUrl=lastTrack.url;if(activity.name.includes("{{")){for(const key in lastTrack){activity.name=activity.name.replace(`{{${key}}}`,lastTrack[key]);}}if(currentSettings.showTimestamp){activity.timestamps={start:Date.now()/1e3|0};}if(lastTrack.album){activity.assets={large_image:await fetchAsset(lastTrack.albumArt),large_text:`on ${lastTrack.album}`};}verboseLog("--> Setting activity...");verboseLog(activity);try{sendRequest(activity);}catch(err){verboseLog("--> An error occurred while setting the activity");clearActivity();throw err}verboseLog("--> Successfully set activity!");}function flush(){console.log("--> Flushing...");global.lastActivity=null;global.lastTrackUrl=null;global.updateInterval&&clearInterval(global.updateInterval);clearActivity();}async function initialize(){console.log("--> Initializing...");if(global.pluginStopped){throw new Error("Plugin is already stopped!")}flush();let tries=0;await update().catch(function(err){console.error(err);tries++;});global.updateInterval=setInterval(function(){return update().then(function(){tries=0;}).catch(function(err){console.error(err);if(++tries>3){console.error("Failed to fetch/set activity 3 times, aborting...");flush();}})},(currentSettings.timeInterval||Constants.DEFAULT_TIME_INTERVAL)*1e3);} +const{ScrollView,TouchableOpacity,Text}=common.ReactNative;const{FormInput,FormDivider,FormSwitchRow,FormText,FormIcon}=components.Forms;function UpdateButton(){async function onPressCallback(){for(const key in plugin.storage){if(plugin.storage[key]===false||plugin.storage[key]){currentSettings[key]=plugin.storage[key];}}console.log("Applying settings...");await initialize();toasts.showToast("Settings updated!",assets.getAssetIDByName("Check"));}return common.React.createElement(TouchableOpacity,{onPress:onPressCallback},common.React.createElement(FormText,{style:{marginRight:12}},"UPDATE"))}function Settings(){const settings=storage.useProxy(plugin.storage);const navigation=common.NavigationNative.useNavigation();common.React.useEffect(function(){navigation.setOptions({title:"Last.fm Configuration",headerRight:UpdateButton});},[]);return common.React.createElement(ScrollView,null,common.React.createElement(FormInput,{value:settings.appName||undefined,onChangeText:function(value){return settings.appName=value.trim()},title:"Discord Application Name",placeholder:Constants.DEFAULT_APP_NAME,returnKeyType:"done"}),common.React.createElement(FormDivider,null),common.React.createElement(FormInput,{required:true,value:settings.username||undefined,onChangeText:function(value){return settings.username=value.trim()},title:"Last.fm username",helpText:!settings.username&&common.React.createElement(Text,{style:{color:"#FF0000"}},"This field is required!"),placeholder:"wumpus123",returnKeyType:"done"}),common.React.createElement(FormDivider,null),common.React.createElement(FormInput,{value:settings.timeInterval,onChangeText:function(value){return settings.timeInterval=Number(value)},title:"Update interval (in seconds)",placeholder:Constants.DEFAULT_TIME_INTERVAL.toString(),keyboardType:"numeric",returnKeyType:"done"}),common.React.createElement(FormDivider,null),common.React.createElement(FormSwitchRow,{label:"Show time elapsed",subLabel:"Show the time elapsed since the song started playing",leading:common.React.createElement(FormIcon,{source:assets.getAssetIDByName("clock")}),value:settings.showTimestamp,onValueChange:function(value){return settings.showTimestamp=value}}),common.React.createElement(FormDivider,null),common.React.createElement(FormSwitchRow,{label:"Set status as listening",subLabel:'Set your status as "Listening to" instead of "Playing"',leading:common.React.createElement(FormIcon,{source:assets.getAssetIDByName("ic_headset_neutral")}),value:settings.listeningTo,onValueChange:function(value){return settings.listeningTo=value}}),common.React.createElement(FormDivider,null),common.React.createElement(FormSwitchRow,{label:"Verbose logging",subLabel:"Log more information to the console for debugging purposes",leading:common.React.createElement(FormIcon,{source:assets.getAssetIDByName("pencil")}),value:settings.verboseLogging,onValueChange:function(value){return settings.verboseLogging=value}}))}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}const global={};const currentSettings={..._vendetta.plugin.storage};const UserStore=metro.findByStoreName("UserStore");const SET_ACTIVITY=metro.findByProps("SET_ACTIVITY").SET_ACTIVITY;const verboseLog=function(){for(var _len=arguments.length,message=new Array(_len),_key=0;_key<_len;_key++){message[_key]=arguments[_key];}return currentSettings.verboseLogging&&console.log(...message)};var index = new(function(){function LastFM(){_classCallCheck(this,LastFM);this.settings=Settings;}var _proto=LastFM.prototype;_proto.onLoad=function onLoad(){console.log("Starting last.fm plugin..");global.pluginStopped=false;if(UserStore.getCurrentUser()){console.log("User is already logged in, initializing...");initialize().catch(console.error);}common.FluxDispatcher.subscribe("CONNECTION_OPEN",function(){initialize().catch(console.error);});};_proto.onUnload=function onUnload(){console.log("Stopping last.fm...");global.pluginStopped=true;flush();};return LastFM}());exports.SET_ACTIVITY=SET_ACTIVITY;exports.UserStore=UserStore;exports.currentSettings=currentSettings;exports.default=index;exports.global=global;exports.verboseLog=verboseLog;Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},vendetta,vendetta.metro,vendetta.metro.common,vendetta.plugin,vendetta.storage,vendetta.ui.assets,vendetta.ui.components,vendetta.ui.toasts); \ No newline at end of file diff --git a/Last.fm/manifest.json b/Last.fm/manifest.json index f07f8fc..8083756 100644 --- a/Last.fm/manifest.json +++ b/Last.fm/manifest.json @@ -1 +1 @@ -{"name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"ic_stage_music"},"hash":"791791ff254d47c04f1ddcf461601121457989d41688c9d5756c79e4e6491298"} \ No newline at end of file +{"name":"Last.fm","description":"Show off your last.fm status on your Discord profile.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"ic_stage_music"},"hash":"1087f232a8340002a9e8e03369f651085c7bcba655d7391fb20884056d9346d0"} \ No newline at end of file diff --git a/MoreConfirm/index.js b/MoreConfirm/index.js index 29d6a07..b6cd32f 100644 --- a/MoreConfirm/index.js +++ b/MoreConfirm/index.js @@ -1,4 +1,4 @@ -!function(t,o,e){"use strict";/*! +(function(exports,_vendetta,metro){'use strict';/*! * https://github.com/amsyarasyiq/aliucordrn-plugins/blob/6c0be39ca673c6ebcf48c0f397246b76d578aa26/MoarConfirm/index.tsx * * Copyright (c) 2022 Amsyar Rasyiq @@ -15,4 +15,4 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . -*/let n=e.findByProps("show","confirm","close"),r=e.findByProps("handleStartCall"),a=function(){function t(){!function(t,o){if(!(t instanceof o))throw TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.onLoad=function(){o.logger.log("MoreConfirm: patching calls..."),o.patcher.instead("handleStartCall",r,function(t,e){let[{rawRecipients:[{username:r,discriminator:a},l]},c]=t,i=c?"video call":"call";n.show({title:l?`MoreConfirm: Start a group ${i}?`:`MoreConfirm: Start a ${i} with ${r}#${a}?`,body:l?"Are you sure you want to start the group call?":`Are you sure you want to ${i} ${r}#${a}?`,confirmText:"Yes",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){try{e(...t)}catch(t){o.logger.error("Failed to start call",t)}}})})},t}();t.default=a,Object.defineProperty(t,"__esModule",{value:!0})}({},vendetta,vendetta.metro); \ No newline at end of file +*/function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}const dialog=metro.findByProps("show","confirm","close");const CallManager=metro.findByProps("handleStartCall");var index = new(function(){function MoreConfirm(){_classCallCheck(this,MoreConfirm);}var _proto=MoreConfirm.prototype;_proto.onLoad=function onLoad(){_vendetta.logger.log("MoreConfirm: patching calls...");_vendetta.patcher.instead("handleStartCall",CallManager,function(args,orig){const[{rawRecipients:[{username,discriminator},multiple]},isVideo]=args;const action=isVideo?"video call":"call";dialog.show({title:multiple?`MoreConfirm: Start a group ${action}?`:`MoreConfirm: Start a ${action} with ${username}#${discriminator}?`,body:multiple?"Are you sure you want to start the group call?":`Are you sure you want to ${action} ${username}#${discriminator}?`,confirmText:"Yes",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){try{orig(...args);}catch(e){_vendetta.logger.error("Failed to start call",e);}}});});};return MoreConfirm}());exports.default=index;Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},vendetta,vendetta.metro); \ No newline at end of file diff --git a/MoreConfirm/manifest.json b/MoreConfirm/manifest.json index 3e2d48f..8e3009e 100644 --- a/MoreConfirm/manifest.json +++ b/MoreConfirm/manifest.json @@ -1 +1 @@ -{"name":"MoreConfirm","description":"Prompts confirmations before making irreversible actions.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"check"},"hash":"cba9c7a3326d2eaf34b3a0ad8795940d1721ad929146b21db556fefc9f82d323"} \ No newline at end of file +{"name":"MoreConfirm","description":"Prompts confirmations before making irreversible actions.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"check"},"hash":"94e433cbfbd4551fc7bed612eaec9d5c68ca645d9df0cb4bc6be762d22958cb8"} \ No newline at end of file diff --git a/NoIdle/index.js b/NoIdle/index.js index fec1c70..72ff89e 100644 --- a/NoIdle/index.js +++ b/NoIdle/index.js @@ -1 +1 @@ -!function(t,e,n){"use strict";let o;let i=function(){function t(){!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,t)}var i=t.prototype;return i.onLoad=function(){e.logger.log("Starting NoIdle..."),o=e.patcher.before("dispatch",n.FluxDispatcher,function(t){let[{type:e}]=t;if("IDLE"===e)return[{type:"IDLE",idle:!1}]})},i.onUnload=function(){e.logger.log("Disabling NoIdle.."),o?.()},t}();t.default=i,Object.defineProperty(t,"__esModule",{value:!0})}({},vendetta,vendetta.metro.common); \ No newline at end of file +(function(exports,_vendetta,common){'use strict';function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}let unpatch;var index = new(function(){function NoIdle(){_classCallCheck(this,NoIdle);}var _proto=NoIdle.prototype;_proto.onLoad=function onLoad(){_vendetta.logger.log("Starting NoIdle...");unpatch=_vendetta.patcher.before("dispatch",common.FluxDispatcher,function(param){let[{type}]=param;if(type!=="IDLE")return;return [{type:"IDLE",idle:false}]});};_proto.onUnload=function onUnload(){_vendetta.logger.log("Disabling NoIdle..");unpatch?.();};return NoIdle}());exports.default=index;Object.defineProperty(exports,'__esModule',{value:true});return exports;})({},vendetta,vendetta.metro.common); \ No newline at end of file diff --git a/NoIdle/manifest.json b/NoIdle/manifest.json index 6b7be0f..11bd798 100644 --- a/NoIdle/manifest.json +++ b/NoIdle/manifest.json @@ -1 +1 @@ -{"name":"NoIdle","description":"Prevent status from idling when Discord is in the background.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"StatusIdle"},"hash":"30d9755940198cb7ef712d4b13bc55a6f49454ba48496ba986a5df7e7e80e58c"} \ No newline at end of file +{"name":"NoIdle","description":"Prevent status from idling when Discord is in the background.","authors":[{"name":"amsyarasyiq","id":"492949202121261067"}],"main":"index.js","vendetta":{"icon":"StatusIdle"},"hash":"256e4ec951c2e6cd397f16fe007ac0ca68ad3b63ec43acc8d8d23834dbe31b63"} \ No newline at end of file