🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

YouTube Speed Booster х2 on/off

Добавляет кнопку изменения скорости на YouTube возле Аккаунта.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name        YouTube Speed Booster х2 on/off
// @namespace   Violentmonkey Scripts
// @match       *://www.youtube.com/*
// @grant       none
// @version     1.6
// @author      -
// @description Добавляет кнопку изменения скорости на YouTube возле Аккаунта.
// @license
// @license MIT
// ==/UserScript==
const top = '12px'; // Меняйте если надо Положение кнопки отступа ОТ Верха
const right = '240px'; // Меняйте если надо Положение кнопки отсупа ОТ Павого борта.

let currentSpeedIndex = parseInt(localStorage.getItem('currentSpeedIndex')) || 0;
const speeds = [1.5, 2.0, 1.0, 0];
const speedButton = document.createElement('button');
let currentQualityIndex = parseInt(localStorage.getItem('currentQualityIndex')) || 0;

function setPlaybackSpeed() {
    const video = document.querySelector('video');
    if (video) {
        const currentSpeed = speeds[currentSpeedIndex];
        if (isMusicVideo()) {
            video.playbackRate = 1.0;
            currentSpeedIndex = 2; // Устанавливаем индекс на 1.0 для музыкальных видео
            localStorage.setItem('currentSpeedIndex', currentSpeedIndex);
        } else {
            if (currentSpeed > 0) {
                video.playbackRate = currentSpeed;
            }
        }
        speedButton.textContent = currentSpeed > 0 ? `Скорость ${currentSpeed}x` : 'Состояние Выкл';
    }
}

function isMusicVideo() {
    const videoTitle = document.title.toLowerCase();
    return /music|MV|AMV|song|official audio|official music video|clip|live|live performance|cover|музыка|песня|официальный аудио|официальный музыкальный видеоролик|клип|музыкальный клип|прямая трансляция|прямой эфир/i.test(videoTitle) || // Russia
           /musique|chanson|audio officiel|vidéo musicale officielle|clip|live|performance en direct|reprise/i.test(videoTitle) || // French
           /musik|lied|offizielle audio|offizielles musikvideo|clip|live-performance|cover|livestream/i.test(videoTitle) || // German
           /musica|canción|audio oficial|video musical oficial|clip|actuación en vivo|versión de|transmisión en vivo/i.test(videoTitle) || // Spanish
           /musica|canzone|audio ufficiale|video musicale ufficiale|clip|esibizione dal vivo|cover|diretta/i.test(videoTitle); // Italian
}

function toggleSpeed() {
  currentSpeedIndex = (currentSpeedIndex + 1) % speeds.length;
  localStorage.setItem('currentSpeedIndex', currentSpeedIndex);
  if (speeds[currentSpeedIndex] === 0) {
    speedButton.textContent = 'Состояние Выкл'; // Текст для состояния "выкл"
  } else {
    speedButton.textContent = `Скорость ${speeds[currentSpeedIndex]}x`;
  }
  setPlaybackSpeed();
}

speedButton.textContent = `Скорость ${speeds[currentSpeedIndex]}x`;
speedButton.title = 'Нажмите для переключения скорости воспроизведения.';
speedButton.style.position = 'fixed';
speedButton.style.top = top;
speedButton.style.right = right;
speedButton.style.zIndex = '9999';
speedButton.style.padding = '10px 10px';
speedButton.style.backgroundColor = '#ff0000';
speedButton.style.color = '#ffffff';
speedButton.style.border = 'none';
speedButton.style.borderRadius = '50px';
speedButton.style.cursor = 'pointer';
speedButton.style.fontSize = '10px';

document.body.appendChild(speedButton);
speedButton.addEventListener('click', toggleSpeed);

window.addEventListener('load', () => {setPlaybackSpeed();});
document.addEventListener('fullscreenchange', () => {speedButton.style.display = document.fullscreenElement ? 'none' : 'block';});
const observer = new MutationObserver(() => {setPlaybackSpeed();});
observer.observe(document.body, { childList: true, subtree: true });