Skip to content

Instantly share code, notes, and snippets.

@BitesizedLion
Last active May 3, 2023 21:28
Show Gist options
  • Save BitesizedLion/3693e3aebf8caf2dd427e6b8c7ddec74 to your computer and use it in GitHub Desktop.
Save BitesizedLion/3693e3aebf8caf2dd427e6b8c7ddec74 to your computer and use it in GitHub Desktop.
Anonymized Radios w/ track context menu
// NAME: Anonymized Radios
(function anonymizedradios() {
const { Platform, URI } = Spicetify;
async function makePlaylist(uris) {
const trackID = uris[0].substr(8);
const sse = new EventSource(
`https://open.spoqify.com/anonymize?url=${trackID}`
);
sse.addEventListener("done", function (e) {
sse.close();
let anonymizedURL = e.data.replace("https://open.spotify.com", "");
Spicetify.Platform.History.replace(anonymizedURL);
});
sse.addEventListener("error", function (e) {
sse.close();
// toast or something?
});
}
function shouldDisplayContextMenu(uris) {
if (uris.length > 1) return false;
const uri = uris[0];
const uriObj = Spicetify.URI.fromString(uri);
if (uriObj.type === Spicetify.URI.Type.TRACK) {
return true;
}
return false;
}
const cntxMenu = new Spicetify.ContextMenu.Item(
"Create anonymized playlist",
makePlaylist,
shouldDisplayContextMenu
);
cntxMenu.register();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment