Greasy Fork 还支持 简体中文。

Skip Copyright in ZJU Classroom

this script speed up the video loading by skipping Copyright video in ZJU Classroom

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Skip Copyright in ZJU Classroom
// @namespace    http://tampermonkey.net/
// @version      2024-04-06
// @description  this script speed up the video loading by skipping Copyright video in ZJU Classroom
// @author       You
// @match        https://classroom.zju.edu.cn/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to dispatch an 'ended' event
    function dispatchEndedEvent(target) {
        // Create and dispatch the 'ended' event
        Promise.resolve().then(() => {
            const event = new Event('ended');
            target.dispatchEvent(event);
            //console.log('Ended event dispatched on #copy-right-video');
        });
    }

    // MutationObserver callback function
    function observerCallback(mutationsList, observer) {
        for(let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                mutation.addedNodes.forEach(node => {
                    // Check if the added node is the target element or contains the target element
                    if (node.id === 'copy-right-video') {
                        dispatchEndedEvent(node);
                        observer.disconnect(); // Stop observing after the event is dispatched
                    } else if (node.querySelector) {
                        const targetElement = node.querySelector('#copy-right-video');
                        if (targetElement) {
                            dispatchEndedEvent(targetElement);
                            observer.disconnect(); // Stop observing after the event is dispatched
                        }
                    }
                });
            }
        }
    }

    // Create an observer instance linked to the callback function
    const observer = new MutationObserver(observerCallback);

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

})();