Greasy Fork

Greasy Fork is available in English.

Bandcamp: Wishlist Auto Play

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

目前为 2023-09-26 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bandcamp: Wishlist Auto Play
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Auto-playing tracks on https://bandcamp.com on the "wishlist" page
// @author       Grihail
// @match        https://bandcamp.com/*wishlist
// @match        https://bandcamp.com/tag/*
// @icon         https://s4.bcbits.com/img/favicon/favicon-32x32.png
// @grant        none
// @license       CC-BY
// ==/UserScript==

if (window.location.href.match(/https:\/\/bandcamp\.com.*\/wishlist/)) {
  const playlistItems = document.querySelectorAll('#wishlist-items > ol > li');
  let previousTrackIndex = -1;

  setInterval(() => {
    const playingTrack = document.querySelector('#wishlist-items > ol > li.playing');
    const progressBar = document.querySelector('#carousel-player > div > div.col.col-7-15.progress-transport > div.info-progress > div.progress-bar > div.progress');

    if (playingTrack) {
      const currentTrackIndex = Array.from(playlistItems).indexOf(playingTrack);
      if (currentTrackIndex !== previousTrackIndex) {
        previousTrackIndex = currentTrackIndex;
      }
    } else if (progressBar && progressBar.style.width === '100%') {
      const nextTrackImage = document.querySelector('#wishlist-items > ol > li:nth-child(' + (previousTrackIndex + 2) + ') img');
      if (nextTrackImage) {
        nextTrackImage.click();
      } else {
        const showMoreButton = document.querySelector('.show-more');
        if (showMoreButton) {
          showMoreButton.click();
        }
      }
    }
  }, 1000);
}
if (window.location.href.match(/https:\/\/bandcamp\.com\/tag\/*/)) {
	const playlistItems = document.querySelectorAll('.dig-deeper-items > div:nth-child(1) > div');
	let previousTrackIndex = -1;
	
	setInterval(() => {
	const playingTrack = document.querySelector('.dig-deeper-items > div:nth-child(1) > div.playing');
	const progressBar = document.querySelector('#carousel-player > div > div.col.col-7-15.progress-transport > div.info-progress > div.progress-bar > div.progress');
	
		if (playingTrack) {
		const currentTrackIndex = Array.from(playlistItems).indexOf(playingTrack);
		if (currentTrackIndex !== previousTrackIndex) {
		previousTrackIndex = currentTrackIndex;
		}
	
	} else if (progressBar && progressBar.style.width === '100%') {
		const nextTrackImage = document.querySelector('.dig-deeper-items > div:nth-child(1) > div:nth-child(' + (previousTrackIndex + 2) + ') .art');
		if (nextTrackImage) {
			nextTrackImage.click();
		} else {
			const showMoreButton = document.querySelector('.view-more');
		if (showMoreButton) {
	        showMoreButton.click();
		}
		}
		}
	}, 1000);
}