Greasy Fork

Greasy Fork is available in English.

Bandcamp Wishlist AutoPlay

Auto-playing tracks on https://bandcamp.com on the "wishlist" page

当前为 2023-08-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bandcamp Wishlist AutoPlay
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto-playing tracks on https://bandcamp.com on the "wishlist" page
// @author       Grihail
// @match        https://bandcamp.com/*wishlist
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bandcamp.com
// @grant        none
// @license       CC-BY
// ==/UserScript==

(function() {
    'use strict';

    let playingIndex = null;
    let isNotificationShown = false;

    const clickNextItem = (item) => {
        const nextItem = item.nextElementSibling;
        if (nextItem !== null) {
            const img = nextItem.querySelector('img');
            img.click();
        }
    };

    const checkPlaying = () => {
        const items = document.querySelectorAll('#wishlist-items > ol > li');
        for (let i = 0; i < items.length; i++) {
            const item = items[i];
            if (item.classList.contains('playing')) {
                if (playingIndex !== i) {
                    playingIndex = i;
                }
                return;
            }
        }
        if (playingIndex !== null) {
            const progressBar = document.querySelector('#carousel-player > div > div.col.col-7-15.progress-transport > div.info-progress > div.progress-bar > div.progress');
            const width = parseFloat(progressBar?.style.width || '0');
            if (width >= 100) {
                clickNextItem(items[playingIndex]);
            }
        }
    };

    setInterval(checkPlaying, 500);
})();