syntax.fm

syntax 控制

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         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)
  })();