Remove Spotify Now Playing View

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 });
})();