Open in Spotify Desktop client

Opens spotify links in the desktop app

  1. // ==UserScript==
  2. // @name Open in Spotify Desktop client
  3. // @description Opens spotify links in the desktop app
  4. // @version 1.3
  5. // @author yungsamd17
  6. // @namespace https://github.com/yungsamd17/UserScripts
  7. // @license MIT License
  8. // @icon https://raw.githubusercontent.com/yungsamd17/UserScripts/main/scripts/icons/Open-in-Spotify.png
  9. // @match https://open.spotify.com/*
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var data=document.URL.match(/[\/\&](track|playlist|album|artist|user|show|episode)\/([^\&\#\/\?]+)/i);
  16. console.log("This is a "+data[1]+" with id:"+data[2]+"\nAttempting to redirect");
  17. window.location.replace('spotify:'+data[1]+':'+data[2]);
  18. window.close(); // Close tab instantly
  19. })();