syntax.fm

syntax 控制

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.

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

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         syntax.fm
// @namespace    ziggy chen
// @license MIT
// @version      0.2
// @description  syntax 控制
// @author       Ziggy chen
// @match        *://syntax.fm/*
// @icon         https://syntax.fm/favicon.png
// @run-at       document-start
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';
    // 创建控制按钮
    const btn = document.createElement('button');
    btn.id = 'speedControlBtn';
    btn.style.cssText = `
        position: fixed;
        bottom: 110px;
        right: 20px;
        z-index: 9999;
        padding: 4x 8px 4px 8px !important;
        background-color: #4CAF50;
        color: white;
        border: none;
        font-size: 12px;
        border-radius: 4px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    `;
    // 状态管理
    let isActive = false;
    let intervalId = null;
  
    // 更新按钮状态
    function updateButtonState() {
        btn.textContent = isActive ? '0.8x': '1x';
        btn.style.backgroundColor = isActive ? '#4CAF50' : '#f44336';
    }
    // 主控制函数
    function toggleSpeedControl() {
        isActive = !isActive;
  
        if (isActive) {
            // 创建定时器
            intervalId = setInterval(() => {
                const audio = document.querySelector('audio');
                if (audio && audio.playbackRate !== 0.8) {
                    audio.playbackRate = 0.8;
                }
            }, 1000);
        } else {
            // 清除定时器
            if (intervalId) {
                clearInterval(intervalId);
                 const audio = document.querySelector('audio');
                if (audio && audio.playbackRate === 0.8) {
                    audio.playbackRate = 1;
                }
                intervalId = null;
            }
        }
  
        updateButtonState();
    }
    // 初始化
    btn.addEventListener('click', toggleSpeedControl);
    updateButtonState();
    document.body.appendChild(btn);
    // 自动检测新添加的audio元素
    new MutationObserver(() => {
        if (isActive) {
            const audio = document.querySelector('audio');
            if (audio && audio.playbackRate !== 0.8) {
                audio.playbackRate = 0.8;
            }
        }
    }).observe(document.body, {
        childList: true,
        subtree: true
    });
    // 快进 退后
    let changeSeek = false
    const seekTimer = setInterval(() => {
        if (changeSeek)  {
            clearInterval(seekTimer)
            return
        }

        const seekBtns =document.querySelectorAll("*[seekoffset]")
        console.log("🚀 ~ seekBtns:", seekBtns)
        if (seekBtns?.length) {
            changeSeek = true
            for (const btn of seekBtns) {
                btn.setAttribute('seekoffset', 2)
                console.log(btn)
            }
        }
    }, 1000)
  })();