Remove Spotify Now Playing View

Remove the Now Playing view element and div with a specific class from the page

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Remove Spotify Now Playing View
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Remove the Now Playing view element and div with a specific class from the page
// @author       Drewby123
// @match        *://open.spotify*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log('Tampermonkey script loaded');

    function removeNowPlayingView() {
        // Remove the Now Playing view by ID
        const nowPlayingView = document.getElementById('Desktop_PanelContainer_Id');
        if (nowPlayingView) {
            nowPlayingView.remove();
            console.log('Now Playing view removed');
        }

        // Remove the div with class OTfMDdomT5S7B5dbYTT8
        const specificDiv = document.querySelector('.OTfMDdomT5S7B5dbYTT8');
        if (specificDiv) {
            specificDiv.remove();
            console.log('Div with class OTfMDdomT5S7B5dbYTT8 removed');
        }
    }

    // Run the function when the page is fully loaded
    window.addEventListener('load', removeNowPlayingView);

    // Observe the document for dynamically added elements
    const observer = new MutationObserver(() => removeNowPlayingView());
    observer.observe(document.body, { childList: true, subtree: true });
})();