Spotify unblock right click and text selection

This userscript restores the ability to right-click and select text on the Spotify web page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Spotify unblock right click and text selection
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  This userscript restores the ability to right-click and select text on the Spotify web page
// @author       aqemi
// @match        https://open.spotify.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=spotify.com
// @grant        none
// @license MIT
// ==/UserScript==



(async function() {
    'use strict';

    async function waitForElement(selector, win = window) {
        return new Promise(resolve => {
            const interval = setInterval(() => {
                const node = win.document.querySelector(selector);
                if (node) {
                    clearInterval(interval);
                    resolve(node);
                }
            }, 250);
        });
    }

    const css = `
    * {
      user-select: text; !important;
    }`;


    const nativeEventListener = EventTarget.prototype.addEventListener;

    EventTarget.prototype.addEventListener = function (event, ...args) {
        if (!['contextmenu'].includes(event)) {
            nativeEventListener.call(this, event, ...args);
        }
    };

    window.addEventListener('load', async () => {
        try {
            const style = document.createElement('style');
            style.innerHTML = css;
            document.head.appendChild(style);
            setInterval(() => {
                document.querySelectorAll('[draggable=true]').forEach(element => {
                    element.draggable = false;
                });
            }, 1000);
        } catch(error) {
            console.error(error);
        }
    });
})();