Spotify open in app

This userscript redirects open.spotify.com links to the desktop app

  1. // ==UserScript==
  2. // @name Spotify open in app
  3. // @author OrdinaryDog
  4. // @description This userscript redirects open.spotify.com links to the desktop app
  5. // @version 1.2
  6. // @license MIT License
  7. // @copyright Copyright (C) 2019, by ordinarydog@protonmail.com
  8. // @match http://open.spotify.com/*
  9. // @match https://open.spotify.com/*
  10. // @namespace https://greatest.deepsurf.us/users/172431
  11. // @run-at document-start
  12. // @noframes
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var data=document.URL.match(/[\/\&](track|playlist|album|artist|show|episode)\/([^\&\#\/\?]+)/i);
  18. console.log("This is a "+data[1]+" with id:"+data[2]+"\nAttempting to redirect");
  19. window.location.replace('spotify:'+data[1]+':'+data[2]);
  20. })();