Skip to content

Commit

Permalink
feat(plugins/openInApp) Add tidal support (#2404)
Browse files Browse the repository at this point in the history
Co-authored-by: vee <vendicated@riseup.net>
  • Loading branch information
Aztup and Vendicated committed May 15, 2024
1 parent 4d57267 commit f4d6461
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const ALLOWED_PROTOCOLS = [
"steam:",
"spotify:",
"com.epicgames.launcher:",
"tidal:"
];

export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
21 changes: 20 additions & 1 deletion src/plugins/openInApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/;
const SteamMatcher = /^https:\/\/(steamcommunity\.com|(?:help|store)\.steampowered\.com)\/.+$/;
const EpicMatcher = /^https:\/\/store\.epicgames\.com\/(.+)$/;
const TidalMatcher = /^https:\/\/tidal\.com\/browse\/(track|album|artist|playlist|user|video|mix)\/(.+)(?:\?.+?)?$/;

const settings = definePluginSettings({
spotify: {
Expand All @@ -42,14 +43,19 @@ const settings = definePluginSettings({
type: OptionType.BOOLEAN,
description: "Open Epic Games links in the Epic Games Launcher",
default: true,
},
tidal: {
type: OptionType.BOOLEAN,
description: "Open Tidal links in the Tidal app",
default: true,
}
});

const Native = VencordNative.pluginHelpers.OpenInApp as PluginNative<typeof import("./native")>;

export default definePlugin({
name: "OpenInApp",
description: "Open Spotify, Steam and Epic Games URLs in their respective apps instead of your browser",
description: "Open Spotify, Tidal, Steam and Epic Games URLs in their respective apps instead of your browser",
authors: [Devs.Ven],
settings,

Expand Down Expand Up @@ -127,6 +133,19 @@ export default definePlugin({
return true;
}

tidal: {
if (!settings.store.tidal) break tidal;

const match = TidalMatcher.exec(url);
if (!match) break tidal;

const [, type, id] = match;
VencordNative.native.openExternal(`tidal://${type}/${id}`);

event?.preventDefault();
return true;
}

// in case short url didn't end up being something we can handle
if (event?.defaultPrevented) {
window.open(url, "_blank");
Expand Down

0 comments on commit f4d6461

Please sign in to comment.