Spotify Miniplayer Unlocker

Removes the Premium resize popup in Spotify's miniplayers.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Spotify Miniplayer Unlocker
// @namespace    https://open.spotify.com/
// @version      1.0.1
// @description  Removes the Premium resize popup in Spotify's miniplayers.
// @author       shmo
// @license      MIT
// @match        https://open.spotify.com/*
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    function killPopup(doc) {
        var popup = doc.querySelector('.gDrPbJQiN4Ij2XGL');
        if (!popup) return;
        popup.style.setProperty('display', 'none', 'important');
        var notNow = popup.querySelector('.kaOb9iL_4FaiiHH9');
        if (!notNow) {
            var all = popup.querySelectorAll('[data-encore-id="buttonTertiary"]');
            notNow = all[all.length - 1] || null;
        }
        if (notNow) notNow.click();
    }

    function setupInPiP(doc, pipWin) {

        if (!doc.getElementById('smu-suppress')) {
            try {
                var s = doc.createElement('style');
                s.id = 'smu-suppress';
                s.textContent = '.gDrPbJQiN4Ij2XGL { display: none !important; }';
                (doc.head || doc.documentElement).appendChild(s);
            } catch (e) { /* mario kart */ }
        }

        if (!doc._smuObserver) {
            var root = doc.querySelector('.encore-dark-theme') || doc.documentElement;
            doc._smuObserver = new MutationObserver(function () {
                killPopup(doc);
            });
            doc._smuObserver.observe(root, {
                attributes:      true,
                attributeFilter: ['style'],
                childList:       true,
                subtree:         true,
            });
            killPopup(doc);
        }
    }

    function injectIntoPiP(pipWin) {
        if (pipWin._smuInjected) return;
        pipWin._smuInjected = true;
        var doc = pipWin.document;
        setupInPiP(doc, pipWin);
        pipWin.addEventListener('load', function () {
            setupInPiP(pipWin.document, pipWin);
        });
        setTimeout(function () { setupInPiP(pipWin.document, pipWin); }, 500);
        setTimeout(function () { setupInPiP(pipWin.document, pipWin); }, 1500);
    }

    function hookPiP() {
        var pip;
        try { pip = unsafeWindow.documentPictureInPicture; } catch (e) {}

        if (!pip) {
            setTimeout(hookPiP, 400);
            return;
        }
        if (pip.__smu__) return;
        pip.__smu__ = true;

        var orig = pip.requestWindow.bind(pip);
        pip.requestWindow = function (opts) {
            return orig(opts).then(function (pipWin) {
                injectIntoPiP(pipWin);
                return pipWin;
            });
        };
        if (pip.window) injectIntoPiP(pip.window);
    }
    function pollForPiP() {
        try {
            var pip = unsafeWindow.documentPictureInPicture;
            if (pip && pip.window && !pip.window._smuInjected) {
                injectIntoPiP(pip.window);
            }
        } catch (e) {}
    }

    hookPiP();
    setInterval(pollForPiP, 1000);

})();