Spotify open in app

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

< Spotify open in appについてのフィードバック

レート:良 – スクリプトは良好に動作する

§
投稿日: 2018/11/12
編集日: 2018/11/12

Works perfectly, thanks! I added a "close tab" to mine

Thanks! 👍🏻

--- spotifylink.old.js  2018-11-12 16:40:19.000000000 +0900
+++ spotifylink.js  2018-11-12 16:40:07.000000000 +0900
@@ -5,6 +5,7 @@
 // @match        http://open.spotify.com/*
 // @match        https://open.spotify.com/*
 // @namespace https://greatest.deepsurf.us/users/172431
+// @grant        window.close
 // ==/UserScript==

 (function() {
@@ -12,4 +13,9 @@
     var data=document.URL.match(/[\/\&](track|playlist|album|artist)\/([^\&\#\/\?]+)/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() {
+      console.log("Closing tab");
+      window.close();
+    }, 500);
 })();
§
投稿日: 2019/01/06

good idea, thanks for sharing! and by adding // @run-at document-start we don't even need to load the web player! Author, please add those changes to your script

§
投稿日: 2019/01/06

Your window.close() extension actually doesn't work for me if combined with // @run-at document-start. Any idea how to fix this?

OrdinaryDog作者
§
投稿日: 2019/01/15

While this works perfectly in Firefox, chromium based browsers show the confirmation dialog inside the tab and do not pause the script execution. If you haven't set the "always open these types of links in the app" checkmark, the tab will close and so will the dialog. I've tried several workarounds, but none of them seem to work perfectly every time. If anyone has any solutions I'm happy to include them, but at the moment I'm not adding a "close tab" behaviour.

§
投稿日: 2019/07/07

Thanks, exactly what I was lacking. +1 for the author to add it

§
投稿日: 2020/04/22
編集日: 2020/04/22

[removed]

返信を投稿

返信を投稿するにはログインしてください