Redirect Apple Music to Windows App

Redirect Apple Music URLs to the Apple Music Windows app.


    // ==UserScript==
    // @name         Redirect Apple Music to Windows App
    // @namespace    https://tampermonkey.net/
    // @version      1.12
    // @description  Redirect Apple Music URLs to the Apple Music Windows app.
    // @author       BunCat09
    // @icon         https://music.apple.com/assets/favicon/favicon-180.png
    // @match        https://music.apple.com/*
    // @grant        none
    // ==/UserScript==
     
    (function() {
        'use strict';
     
        // Redirect Apple Music URLs to the Apple Music app
        const url = window.location.href;
        const appUrl = url.replace("https://music.apple.com", "music://music.apple.com");
     
        // Launch the app
        window.location.href = appUrl;
     
        // Close the browser tab
        setTimeout(() => {
            window.close();
        }, 1000); // Wait for redirection to ensure the app launches
    })();