Greasy Fork

Greasy Fork is available in English.

Yandex Music Prev Button Extension (One)

Разблокирует кнопку назад в Яндекс волне (анлок вырезанного функционала)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Yandex Music Prev Button Extension (One)
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Разблокирует кнопку назад в Яндекс волне (анлок вырезанного функционала)
// @icon        https://raw.githubusercontent.com/doctored11/YandexMusicPreviousTrack/main/source/YanUnlock32.jpg
// @icon64      https://raw.githubusercontent.com/doctored11/YandexMusicPreviousTrack/main/source/YanUnlock64.jpg
// @author       doctored11
// @match        https://music.yandex.ru/*
// @grant        none
// @license      MIT


// ==/UserScript==

(function () {
    'use strict';
    const style = document.createElement('style');
    style.textContent = `
    .player-controls__btn_prev.disabled {
        display: inline-block;
        opacity: 0.15;
        cursor: not-allowed;
    }
    .player-controls__btn_prev.enabled {
        display: inline-block;
        opacity: 0.5;
        cursor: pointer;
        pointer-events: auto;
    }
    .player-controls__btn_prev.enabled:hover {
        opacity: 1;
    }
    .player-controls__btn_prev.disabled:hover {
        opacity: 0.1;
    }
    .player-controls__track-controls{
        display:flex;
        align-items: center;
    }
   .player-controls__speed-controls{
        display:inline-block !important;
        right:110px;
        transform:translateY(-2px)
   }
    
    ` ;
    document.head.appendChild(style);

    function speedUpdate() {
        const seqControls = document.querySelector('.player-controls__seq-controls');
        const speedControls = document.querySelector('.player-controls__speed-controls');
    
        if (!speedControls || !seqControls) return;
    
        const visibleChildrenCount = Array.from(seqControls.children).filter(child =>
            getComputedStyle(child).display != 'none'
        ).length;
    
        speedControls.style.right = visibleChildrenCount > 1 ? '210px' : '110px';
    }

    function applyStyles(state) {

        const prevButton = document.querySelector('.player-controls__btn_prev');
        if (prevButton) {
            prevButton.classList.remove('disabled', 'enabled');
            prevButton.classList.add(state);
        }
    }

    function updateCurrentTrack() {
        speedUpdate();
        const trackIndex = window.externalAPI?.getTrackIndex();
        applyStyles(trackIndex < 1 ? 'disabled' : 'enabled');
    }

    function goPrev() {
        const currentIndex = window.externalAPI?.getTrackIndex();
        if (currentIndex > 0) {
            window.externalAPI.play(currentIndex - 1);
        }
    }

    function initialize() {
        console.log("Запуск кнопочки");
        const prevButton = document.querySelector('.player-controls__btn_prev');
        if (prevButton) {
            prevButton.addEventListener('click', goPrev);
        }
        updateCurrentTrack();

        if (window.externalAPI) {
            window.externalAPI.on(window.externalAPI.EVENT_TRACK, updateCurrentTrack);
        }
    }
    initialize()
})();