您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Load all of your albums and play random ones
// ==UserScript== // @name Spotify Play Random Album // @namespace http://spotify.com/ // @version 1.0 // @description Load all of your albums and play random ones // @author b2kdaman // @match https://open.spotify.com/collection/albums // @grant none // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // ==/UserScript== (function() { 'use strict'; let albums; let lastAlbumsLength = 0; const SCROLL_NODE_SELECTOR = '.main-view-container__scroll-node'; const LOADING_GIF_SELECTOR = 'img[src="/static/assets/images/loading.gif"]'; const CONTROLS_SELECTOR = '.player-controls__buttons'; const ALBUMS_PLAYBUTTON_SELECTOR = 'button[aria-label="Play"]'; const loaderInterval = setInterval(checkIfStillLoading.bind(window), 1000); const buttonConfig = { className: 'control-button spoticon-track-16', attributes: { title: 'Play Random Album', }, css: { cursor: 'pointer', 'background-color': '#444', color: '#fff', } } function scrollToBottom() { document.querySelector(SCROLL_NODE_SELECTOR).scroll(0, 99999); } function checkIfStillLoading() { scrollToBottom(); if (!$(LOADING_GIF_SELECTOR).length) { loadAlbums(); } } function applyConfig(ref, config) { const attributes = Object.entries(config.attributes); const css = Object.entries(config.css); ref.addClass(config.className); for (const attribute of attributes) { ref.attr(attribute.shift(), attribute.shift()); } for (const cssProp of css) { ref.attr(cssProp.shift(), cssProp.shift()); } } function addButton() { clearInterval(loaderInterval); const playButton = document.createElement('button'); const buttonRef = $(playButton); buttonRef.click(playRandomAlbum); applyConfig(buttonRef, buttonConfig); $(CONTROLS_SELECTOR).prepend(playButton); } function loadAlbums() { albums = $(ALBUMS_PLAYBUTTON_SELECTOR); if (albums.length !== 0 && lastAlbumsLength === albums.length) { addButton(); } else { lastAlbumsLength = albums.length; scrollToBottom(); } } function playRandomAlbum() { albums[Math.round(Math.random() * albums.length)].click(); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址