Greasy Fork

Greasy Fork is available in English.

Udemy Quiz Un-Pauser

Instantly removes the "Your test is paused" modal from the page, leaving the quiz content intact and scrollable.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Udemy Quiz Un-Pauser
// @namespace    http://tampermonkey.net/
// @version      7.0
// @description  Instantly removes the "Your test is paused" modal from the page, leaving the quiz content intact and scrollable.
// @author       Gemini
// @license MIT
// @match        *://www.udemy.com/course/*/quiz/*
// @match        *://www.udemy.com/course/*/learn/quiz/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    /**
     * Attempts to find and click the modal dialog to dismiss it.
     * This function is more reliable as it mimics user interaction.
     */
    function dismissModal() {
        // Target the specific container class that holds the pop-up and its background.
        const dialogContainer = document.querySelector('.modal-module--dialog-container--URcz3');
        if (dialogContainer) {
            console.log('Udemy Quiz Un-Pauser: Found the modal container. Attempting to click it to dismiss.');
            // This click event is the key to solving the issue.
            dialogContainer.click();
        }

        // Failsafe: if the modal is still somehow present, try to find and click the "Resume test" button.
        const resumeButton = document.querySelector('[data-purpose="resume-button"]');
        if (resumeButton) {
            console.log('Udemy Quiz Un-Pauser: Found the "Resume test" button. Clicking it to dismiss the modal.');
            resumeButton.click();
        }
    }

    // Use a MutationObserver to watch for changes to the DOM.
    // This is the most reliable and performant way to catch dynamically added elements.
    const observer = new MutationObserver((mutationsList, obs) => {
        for (let mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                dismissModal();
            }
        }
    });

    // Start observing the document body for new nodes.
    observer.observe(document.body, { childList: true, subtree: true });

    // As a failsafe, also run the check every second in case the observer is missed.
    setInterval(dismissModal, 1000);

})();