Deutsche Welle Out Load Reading

Enhances DW Learn German by improving readability, removing distractions, and adding shortcuts.

当前为 2025-03-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Deutsche Welle Out Load Reading
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Enhances DW Learn German by improving readability, removing distractions, and adding shortcuts.
// @author       Yange
// @match        https://learngerman.dw.com/de/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create a button
    let button = document.createElement('button');
    button.innerText = 'Clean';
    button.style.position = 'fixed';
    button.style.bottom = '20px';
    button.style.right = '20px';
    button.style.padding = '10px';
    button.style.background = 'red';
    button.style.color = 'white';
    button.style.border = 'none';
    button.style.borderRadius = '5px';
    button.style.cursor = 'pointer';
    button.style.zIndex = '9999';

    // Button click event to remove the <nav>
    button.addEventListener('click', function() {
        let currentUrl = window.location.href;
        if (!currentUrl.endsWith('/lm')){
            window.location.href=currentUrl + '/lm';
        }

        let navHeader = document.querySelector('nav.sk35agp');

        if (navHeader) {
            navHeader.remove();
        }

        let navElement = document.querySelector('nav.s1got9be');

        if (navElement) {
            navElement.remove();
        }
    });

    // Add button to the page
    document.body.appendChild(button);

    // Function to toggle play/pause using the Space key
    function togglePlayPause(event) {
        if (event.code === 'Space') { // Check if Space key is pressed
            event.preventDefault(); // Prevent default scrolling behavior

            let playButton = document.querySelector('button.vjs-play-control'); // Find the play button
            if (playButton) {
                playButton.click(); // Simulate clicking the play/pause button
                console.log('Space key pressed: Toggling play/pause');
            } else {
                console.log('Play button not found.');
            }
        }
    }

    // Add event listener for keydown
    document.addEventListener('keydown', togglePlayPause);




    function removeVideo() {
        let videoContainer = document.querySelector('.video-js'); // Select Video.js player

        if (videoContainer) {
            let videoElement = videoContainer.querySelector('video'); // Find <video> inside it

            if (videoElement) {
                videoElement.remove(); // Remove the video element
                console.log('Video removed, audio kept.');
            }

            // Optional: Hide the entire video container (if needed)
            videoContainer.style.height = '50px'; // Make it smaller
            videoContainer.style.background = 'none'; // Remove background
        } else {
            console.log('No video found.');
        }
    }

    window.addEventListener('load', removeVideo);


})();