From 880300e09246004809cf1d79a3290f308a8c7278 Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Fri, 19 Sep 2025 22:03:06 +0200 Subject: [PATCH] deploy --- Last.fm/index.js | 2 +- Last.fm/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Last.fm/index.js b/Last.fm/index.js index c768e59..c5c9094 100644 --- a/Last.fm/index.js +++ b/Last.fm/index.js @@ -1 +1 @@ -(function(S,A,p,g,a,v,d,Y,K){"use strict";const i={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",MIN_UPDATE_INTERVAL:3,MAX_RETRY_ATTEMPTS:3,RETRY_DELAY:5e3,LFM_API_BASE_URL:"https://ws.audioscrobbler.com/2.0",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"],DEFAULT_SETTINGS:{username:"",apiKey:"",appName:"Music",timeInterval:5,showTimestamp:!0,listeningTo:!0,ignoreSpotify:!0,verboseLogging:!1},GITHUB_URL:"https://github.com/kmmiio99o/letup",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/letup/commits/main/"};function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var n=0;ni.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,e;return await new Promise(function(n){return setTimeout(n,i.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||i.LFM_DEFAULT_COVER_HASHES.some(function(n){return e.includes(n)})?null:e}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance();var q=function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t}(q||{});const o=function(...t){return c.verboseLogging&&console.log("[Last.fm]",...t)},M=function(){function t(){P(this,t)}return U(t,[{key:"updateActivity",value:async function(){if(l.pluginStopped){o("Plugin is stopped, skipping update"),this.stopUpdates();return}o("Fetching last track...");try{if(!c.username||!c.apiKey)throw new Error("Username or API key not set");if(c.ignoreSpotify){if(z.findActivity(function(s){return s.sync_id})){o("Spotify is currently playing, clearing activity"),h("isSpotifyIgnored",!0),L();return}h("isSpotifyIgnored",!1)}const e=await F.fetchLatestScrobble();if(h("lastTrack",e),!e.nowPlaying){o("Last track is not currently playing"),L();return}if(l.lastTrackUrl===e.url){o("Track hasn't changed");return}const n={name:c.appName||i.DEFAULT_APP_NAME,flags:0,type:c.listeningTo?2:0,details:e.name,state:e.artist,status_display_type:1,application_id:i.APPLICATION_ID};if(n.name.includes("{{"))for(const s in e)n.name=n.name.replace(`{{${s}}}`,e[s]||"");if(c.showTimestamp&&(n.timestamps={start:Date.now()|0}),e.album){const s=await H([e.albumArt]);s[0]&&(n.assets={large_image:s[0],large_text:e.album})}o("Setting activity:",n),h("lastActivity",n),await D(n),l.lastTrackUrl=e.url,l.lastActivity=n,this.consecutiveFailures=0,o("Activity set successfully!")}catch(e){console.error("[Last.fm] Update error:",e),this.handleError(e)}}},{key:"handleError",value:function(e){this.consecutiveFailures++,h("lastError",e),this.consecutiveFailures>=i.MAX_RETRY_ATTEMPTS&&(o(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),o("Starting reconnection process"),this.reconnectTimer=setInterval(function(){o("Attempting to reconnect..."),e.initialize().then(function(){o("Reconnection successful"),e.stopReconnection()}).catch(function(n){o("Reconnection failed:",n)})},i.RETRY_DELAY))}},{key:"stopReconnection",value:function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=void 0),this.isReconnecting=!1,this.consecutiveFailures=0}},{key:"stopUpdates",value:function(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=void 0)}},{key:"initialize",value:async function(){var e=this;if(l.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(c.timeInterval)||i.DEFAULT_SETTINGS.timeInterval)*1e3,i.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},n),o(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){l.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),L()}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance(),G=function(){return M.initialize()},O=function(){return M.stop()},{FormText:V}=Y.Forms,l={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},$=i.DEFAULT_SETTINGS;for(const t in $)A.plugin.storage[t]=A.plugin.storage[t]??$[t];const c=new Proxy(A.plugin.storage,{get(t,e){return t[e]},set(t,e,n){return t[e]=n,!0}});function B(){return a.React.createElement(v.ScrollView,{style:{flex:1},contentContainerStyle:{padding:16}},a.React.createElement(V,{style:{color:"#ED4245"}},"Failed to load Last.fm settings. Please check your connection and reload Discord."))}const X=K.lazy(async function(){try{return{default:(await Promise.resolve().then(function(){return ne})).default||B}}catch(t){return console.error("[Last.fm] Failed to load settings:",t),{default:B}}});let _=0;const J=3,Q=5e3;async function I(){try{await G(),_=0}catch(t){console.error("[Last.fm] Initialization error:",t),_++,_=i.MIN_UPDATE_INTERVAL?(T("timeInterval",m),n()):g.showToast(`Minimum interval is ${i.MIN_UPDATE_INTERVAL} seconds`,p.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(y,{title:"Options"},a.React.createElement(b,{label:"Show 'Listening to' instead of 'Playing'",value:f("listeningTo",i.DEFAULT_SETTINGS.listeningTo),onValueChange:function(r){T("listeningTo",r),n()}}),a.React.createElement(b,{label:"Show Timestamp",value:f("showTimestamp",i.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(r){T("showTimestamp",r),n()}}),a.React.createElement(b,{label:"Ignore when Spotify is playing",value:f("ignoreSpotify",i.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(r){T("ignoreSpotify",r),n()}}),a.React.createElement(b,{label:"Verbose Logging",value:f("verboseLogging",i.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(r){T("verboseLogging",r),n()}})),a.React.createElement(y,{title:"Plugin Status"},a.React.createElement(u,{label:"Status",subLabel:l.pluginStopped?"Stopped":"Running"}),a.React.createElement(u,{label:"Last Update",subLabel:l.lastTrackUrl?"Success":"No track data"})),a.React.createElement(y,{title:"About"},a.React.createElement(u,{label:"Version",subLabel:Z}),a.React.createElement(u,{label:"View Changelog",trailing:a.React.createElement(u.Arrow,null),onPress:function(){v.Linking.openURL(i.GITHUB_COMMITS_URL)}})),a.React.createElement(y,{title:"Changelog"},W.map(function(r,m){return a.React.createElement(u,{key:m,label:`v${r.version} (${r.date})`,subLabel:r.changes.join(", ")})}))))}var ne=Object.freeze({__proto__:null,default:te});return S.currentSettings=c,S.default=x,S.pluginState=l,Object.defineProperty(S,"__esModule",{value:!0}),S})({},vendetta,vendetta.ui.assets,vendetta.ui.toasts,vendetta.metro.common,vendetta.metro.common.ReactNative,vendetta.metro,vendetta.ui.components,window.React); +(function(S,A,a,f,g,Z,T,N){"use strict";const i={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",MIN_UPDATE_INTERVAL:3,MAX_RETRY_ATTEMPTS:3,RETRY_DELAY:5e3,LFM_API_BASE_URL:"https://ws.audioscrobbler.com/2.0",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"],DEFAULT_SETTINGS:{username:"",apiKey:"",appName:"Music",timeInterval:5,showTimestamp:!0,listeningTo:!0,ignoreSpotify:!0,verboseLogging:!1},GITHUB_URL:"https://github.com/kmmiio99o/letup",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/letup/commits/main/"};function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function U(t,e){for(var n=0;ni.MAX_RETRY_ATTEMPTS)throw this.retryCount=0,e;return await new Promise(function(n){return setTimeout(n,i.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:async function(e){return!e||i.LFM_DEFAULT_COVER_HASHES.some(function(n){return e.includes(n)})?null:e}},{key:"getLastError",value:function(){return this.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance();var Y=function(t){return t[t.PLAYING=0]="PLAYING",t[t.STREAMING=1]="STREAMING",t[t.LISTENING=2]="LISTENING",t[t.COMPETING=5]="COMPETING",t}(Y||{});const l=function(...t){return c.verboseLogging&&console.log("[Last.fm]",...t)},M=function(){function t(){P(this,t)}return k(t,[{key:"updateActivity",value:async function(){if(o.pluginStopped){l("Plugin is stopped, skipping update"),this.stopUpdates();return}l("Fetching last track...");try{if(!c.username||!c.apiKey)throw new Error("Username or API key not set");if(c.ignoreSpotify){if($.findActivity(function(s){return s.sync_id})){l("Spotify is currently playing, clearing activity"),d("isSpotifyIgnored",!0),w();return}d("isSpotifyIgnored",!1)}const e=await F.fetchLatestScrobble();if(d("lastTrack",e),!e.nowPlaying){l("Last track is not currently playing"),w();return}if(o.lastTrackUrl===e.url){l("Track hasn't changed");return}const n={name:c.appName||i.DEFAULT_APP_NAME,flags:0,type:c.listeningTo?2:0,details:e.name,state:e.artist,status_display_type:1,application_id:i.APPLICATION_ID};if(n.name.includes("{{"))for(const s in e)n.name=n.name.replace(`{{${s}}}`,e[s]||"");if(c.showTimestamp&&(n.timestamps={start:Date.now()|0}),e.album){const s=await x([e.albumArt]);s[0]&&(n.assets={large_image:s[0],large_text:e.album})}l("Setting activity:",n),d("lastActivity",n),await D(n),o.lastTrackUrl=e.url,o.lastActivity=n,this.consecutiveFailures=0,l("Activity set successfully!")}catch(e){console.error("[Last.fm] Update error:",e),this.handleError(e)}}},{key:"handleError",value:function(e){this.consecutiveFailures++,d("lastError",e),this.consecutiveFailures>=i.MAX_RETRY_ATTEMPTS&&(l(`Failed ${this.consecutiveFailures} times, initiating reconnection...`),this.startReconnection())}},{key:"startReconnection",value:function(){var e=this;this.isReconnecting||(this.isReconnecting=!0,this.stopUpdates(),l("Starting reconnection process"),this.reconnectTimer=setInterval(function(){l("Attempting to reconnect..."),e.initialize().then(function(){l("Reconnection successful"),e.stopReconnection()}).catch(function(n){l("Reconnection failed:",n)})},i.RETRY_DELAY))}},{key:"stopReconnection",value:function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=void 0),this.isReconnecting=!1,this.consecutiveFailures=0}},{key:"stopUpdates",value:function(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=void 0)}},{key:"initialize",value:async function(){var e=this;if(o.pluginStopped)throw new Error("Plugin is stopped");this.stopUpdates(),await this.updateActivity();const n=Math.max((Number(c.timeInterval)||i.DEFAULT_SETTINGS.timeInterval)*1e3,i.MIN_UPDATE_INTERVAL*1e3);this.updateTimer=setInterval(function(){return e.updateActivity()},n),l(`Update timer started with interval: ${n}ms`)}},{key:"stop",value:function(){o.pluginStopped=!0,this.stopUpdates(),this.stopReconnection(),w()}}],[{key:"getInstance",value:function(){return t.instance||(t.instance=new t),t.instance}}]),t}().getInstance(),G=function(){return M.initialize()},B=function(){return M.stop()},K=[{version:"2.2.0",date:"2025-09-13",changes:["Remember kids! Do not sniff crack!"]},{version:"2.0.0",date:"2025-09-13",changes:["Fix settings scrolling"]},{version:"1.3.0",date:"2025-09-13",changes:["fix reanimated"]},{version:"1.2.0",date:"2025-09-13",changes:["test"]},{version:"1.1.0",date:"2025-09-12",changes:["fixed reanimated issue??"]}],H="2.2.0",{ScrollView:j}=T.findByProps("ScrollView"),{TableRowGroup:y,TableSwitchRow:R,Stack:L,TableRow:u}=T.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow"),{TextInput:b}=T.findByProps("TextInput");T.findByProps("FormText");const p=function(t,e=""){return A.plugin.storage[t]??e},h=function(t,e){return A.plugin.storage[t]=e};function z(){const[t,e]=a.React.useReducer(function(r){return~r},0),n=function(){return e()},[s,E]=a.React.useState(!1),Q=async function(){const r=p("username"),m=p("apiKey");if(!r||!m){g.showToast("Please enter both username and API key",f.getAssetIDByName("Small"));return}E(!0);try{await F.fetchLatestScrobble(),g.showToast("Connection successful!",f.getAssetIDByName("Check")),await G()}catch(W){g.showToast(`Connection failed: ${W.message}`,f.getAssetIDByName("Small"))}finally{E(!1)}};return a.React.createElement(j,{style:{flex:1},contentContainerStyle:{padding:10}},a.React.createElement(L,{spacing:8},a.React.createElement(y,{title:"Account Settings"},a.React.createElement(L,{spacing:4},a.React.createElement(b,{placeholder:"Last.fm Username",value:p("username"),onChange:function(r){h("username",r),n()},isClearable:!0}),a.React.createElement(b,{placeholder:"API Key",value:p("apiKey"),onChange:function(r){h("apiKey",r),n()},secureTextEntry:!0,isClearable:!0}),a.React.createElement(u,{label:"Get API Key",subLabel:"https://www.last.fm/api/account/create",onPress:function(){return N.Linking.openURL("https://www.last.fm/api/account/create")}})),a.React.createElement(u,{label:"Test Connection",trailing:s?a.React.createElement(u.Arrow,{loading:!0}):a.React.createElement(u.Arrow,null),onPress:Q,disabled:s})),a.React.createElement(y,{title:"Display Settings"},a.React.createElement(L,{spacing:4},a.React.createElement(b,{placeholder:`App Name (Default: ${i.DEFAULT_SETTINGS.appName})`,value:p("appName",i.DEFAULT_SETTINGS.appName),onChange:function(r){h("appName",r),n()},isClearable:!0}),a.React.createElement(b,{placeholder:`Update Interval (Default: ${i.DEFAULT_SETTINGS.timeInterval}s)`,value:String(p("timeInterval",i.DEFAULT_SETTINGS.timeInterval)),onChange:function(r){const m=Number(r);m>=i.MIN_UPDATE_INTERVAL?(h("timeInterval",m),n()):g.showToast(`Minimum interval is ${i.MIN_UPDATE_INTERVAL} seconds`,f.getAssetIDByName("Small"))},keyboardType:"numeric",isClearable:!0}))),a.React.createElement(y,{title:"Options"},a.React.createElement(R,{label:"Show 'Listening to' instead of 'Playing'",value:p("listeningTo",i.DEFAULT_SETTINGS.listeningTo),onValueChange:function(r){h("listeningTo",r),n()}}),a.React.createElement(R,{label:"Show Timestamp",value:p("showTimestamp",i.DEFAULT_SETTINGS.showTimestamp),onValueChange:function(r){h("showTimestamp",r),n()}}),a.React.createElement(R,{label:"Ignore when Spotify is playing",value:p("ignoreSpotify",i.DEFAULT_SETTINGS.ignoreSpotify),onValueChange:function(r){h("ignoreSpotify",r),n()}}),a.React.createElement(R,{label:"Verbose Logging",value:p("verboseLogging",i.DEFAULT_SETTINGS.verboseLogging),onValueChange:function(r){h("verboseLogging",r),n()}})),a.React.createElement(y,{title:"Plugin Status"},a.React.createElement(u,{label:"Status",subLabel:o.pluginStopped?"Stopped":"Running"}),a.React.createElement(u,{label:"Last Update",subLabel:o.lastTrackUrl?"Success":"No track data"})),a.React.createElement(y,{title:"About"},a.React.createElement(u,{label:"Version",subLabel:H}),a.React.createElement(u,{label:"View Changelog",trailing:a.React.createElement(u.Arrow,null),onPress:function(){N.Linking.openURL(i.GITHUB_COMMITS_URL)}})),a.React.createElement(y,{title:"Changelog"},K.map(function(r,m){return a.React.createElement(u,{key:m,label:`v${r.version} (${r.date})`,subLabel:r.changes.join(", ")})}))))}const o={pluginStopped:!1,lastActivity:void 0,updateInterval:void 0,lastTrackUrl:void 0},O=i.DEFAULT_SETTINGS;for(const t in O)A.plugin.storage[t]=A.plugin.storage[t]??O[t];const c=new Proxy(A.plugin.storage,{get(t,e){return t[e]},set(t,e,n){return t[e]=n,!0}});let _=0;const q=3,X=5e3;async function I(){try{await G(),_=0}catch(t){console.error("[Last.fm] Initialization error:",t),_++,_