Turntable Lab autoplay

Play all audio samples automatically.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Turntable Lab autoplay
// @namespace    https://www.turntablelab.com/
// @version      0.1
// @description  Play all audio samples automatically.
// @author       Daniel Saner
// @license      GPL v3
// @match        https://www.turntablelab.com/products/*
// @icon         https://www.google.com/s2/favicons?domain=turntablelab.com
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require      https://greatest.deepsurf.us/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var listenerAdded = false;
    var currentTrack = 0;
    var tracks = [];

    waitForKeyElements ('.audio-track', addListener, true);

    function addListener() {
        if (!listenerAdded) {
            listenerAdded = true;
            const element = document.getElementsByClassName('product-gallery__tracks-button')[0];
            element.children[0].textContent = 'PLAY ALL SAMPLES';
            element.addEventListener('click', play);
        }
    }

    function play() {
        tracks = document.getElementsByClassName('audio-track__button');
        tracks[currentTrack].click();
        setTimeout(playNext, 1000);
    }

    function playNext() {
        if (document.getElementsByClassName('audio-track--playing').length < 1) {
            currentTrack++;
            if (tracks.length > currentTrack) {
                tracks[currentTrack].click();
            } else {
                currentTrack = 0;
                return;
            }
        }
        setTimeout(playNext, 1000);
    }
})();