Focus Daily Dictation

Auto-scroll to the dictation element near the top

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

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.

You will need to install a user script manager extension to install this script.

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

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         Focus Daily Dictation
// @namespace    http://tampermonkey.net/
// @version      25.3.1
// @description  Auto-scroll to the dictation element near the top
// @author       clane
// @match        https://dailydictation.com/exercises/*
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function scrollToTarget() {
        // 精确选择包含min-height:400px的row元素
        const target = document.querySelector('.row[style*="min-height: 400px"]');
        if (!target) return false;

        // 计算固定顶栏高度(如果有)
        const header = document.querySelector('header, .fixed-top');
        const offset = header ? header.offsetHeight : 0;

        // 滚动到目标位置
        window.scrollTo({
            top: target.offsetTop - offset,
            behavior: 'smooth'
        });
        return true;
    }

    // 立即尝试执行
    if (!scrollToTarget()) {
        // 设置观察者检测动态加载
        const observer = new MutationObserver(() => scrollToTarget());
        observer.observe(document, {
            childList: true,
            subtree: true
        });

        // 10秒后停止观察(防止长期占用资源)
        setTimeout(() => observer.disconnect(), 10000);
    }
})();