Skip to content

Commit

Permalink
[lastfm] allow bypassing activity privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
redstonekasi authored and yellowsink committed May 20, 2024
1 parent 3beb381 commit cce36d9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
4 changes: 3 additions & 1 deletion plugins/freemoji/slateTreeProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export default (slateTree) => {
) {
// add to emotes to send
extractedEmojis.push(
`https://cdn.discordapp.com/emojis/${emoji.id}?size=${getEmoteSize()}`,
`https://cdn.discordapp.com/emojis/${
emoji.id
}?size=${getEmoteSize()}`,
);
// don't add to the line
continue;
Expand Down
9 changes: 8 additions & 1 deletion plugins/lastfm/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DEFAULT_INTERVAL, DEFAULT_NAME } from "./cfg";
import { Component } from "solid-js";

// @ts-expect-error
const { store } = shelter.plugin;
const {
TextBox,
Expand Down Expand Up @@ -98,6 +97,14 @@ export const settings = () => (
Hide when using Spotify
</SwitchItem>

<SwitchItem
value={store.alwaysShare}
onChange={(v) => (store.alwaysShare = v)}
note="Share activity even if you have activities disabled"
>
Always show activity
</SwitchItem>

<Text>
Thanks to
<LinkButton href="https://github.com/amsyarasyiq/letup/blob/main/plugins/Last.fm">
Expand Down
25 changes: 24 additions & 1 deletion plugins/lastfm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ store.stamp ??= true;
store.ignoreSpotify ??= true;
store.service ??= "lfm";
store.lbLookup ??= true;
store.alwaysShare ??= false;

const UserStore = storesFlat.UserStore as FluxStore<{
getCurrentUser(): { id: string };
Expand Down Expand Up @@ -208,7 +209,29 @@ const restartLoop = () => (
(interval = setInterval(updateStatus, store.interval || DEFAULT_INTERVAL))
);

const unpatch = shelter.patcher.after(
"getActivities",
shelter.flux.stores.LocalActivityStore,
(_, res) => {
if (!store.alwaysShare) return;
res.filter = function (predicate) {
if (!predicate.toString().includes("shouldShowActivity")) {
return Array.prototype.filter.call(this, predicate);
}
return Array.prototype.filter.call(this, (event) => {
if (event?.type === 2 && event.application_id === DISCORD_APP_ID) {
return true;
}
return predicate(event);
});
};
return res;
},
);

restartLoop();
export const onUnload = () => (clearInterval(interval), setPresence());
export const onUnload = () => (
clearInterval(interval), setPresence(), unpatch()
);

export * from "./Settings";

0 comments on commit cce36d9

Please sign in to comment.