Spotify link open in desktop app

This userscript redirects open.spotify.com links to the desktop app and close Spotify tab in browser

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Spotify link open in desktop app
// @author       OrdinaryDog
// @description  This userscript redirects open.spotify.com links to the desktop app and close Spotify tab in browser
// @version      1.3
// @license      MIT License
// @copyright    Copyright (C) 2019, by [email protected]
// @match        http://open.spotify.com/*
// @match        https://open.spotify.com/*
// @namespace    https://greatest.deepsurf.us/users/172431
// @run-at       document-start
// @noframes
// ==/UserScript==

(function () {
  "use strict";
  var data = document.URL.match(
    /[\/\&](track|playlist|album|artist|show|episode)\/([^\&\#\/\?]+)/i
  );
  console.log(
    "This is a " + data[1] + " with id:" + data[2] + "\nAttempting to redirect"
  );
  window.location.replace("spotify:" + data[1] + ":" + data[2]);
  
  setTimeout(function () {
    window.top.close();
  }, 2000);
})();