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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

YouTube Speed Booster х2 on/off

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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

公众号二维码

扫码关注【爱吃馍】

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

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.

(I already have a user style manager, let me install it!)

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

公众号二维码

扫码关注【爱吃馍】

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

// ==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 });