E-Campus VOD Closer

온라인 강의 수강완료 후 알림 및 창 닫기

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         E-Campus VOD Closer
// @namespace    hjh
// @version      0.1
// @description  온라인 강의 수강완료 후 알림 및 창 닫기
// @author       You
// @match        http*://ecampus.changwon.ac.kr/mod/vod/viewer.php?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ac.kr
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function playMelody() {
        // 오디오 컨텍스트 생성
        const AudioContext = window.AudioContext || window.webkitAudioContext;
        const audioCtx = new AudioContext();

        // 각 음계의 주파수 정보
        const frequencies = {
            '도': 261.63,
            '레': 293.66,
            '미': 329.63,
            '파': 349.23,
            '솔': 392.00,
            '라': 440.00,
            '시': 493.88,
        };

        // 도미솔 미디 음계 리스트
        const melody = ['도', '미', '솔'];

        // 오디오 컨텍스트 상수 설정
        const duration = 0.3; // 음 길이 (0.5초)
        const volume = 0.5; // 볼륨 (0.5)

        // 음계를 순회하며 주파수 대역과 음 길이, 볼륨 설정 후 재생
        melody.forEach((note, index) => {
            // 오디오 소스 노드 생성
            const oscillator = audioCtx.createOscillator();
            const gainNode = audioCtx.createGain();

            // 주파수 대역 설정
            oscillator.frequency.setValueAtTime(frequencies[note], audioCtx.currentTime);

            // 음 길이 설정
            const startTime = index * duration;
            const endTime = startTime + duration;
            oscillator.start(startTime);
            oscillator.stop(endTime);

            // 볼륨 설정
            gainNode.gain.setValueAtTime(volume, audioCtx.currentTime);

            // 소스 노드 연결 후 재생
            oscillator.connect(gainNode);
            gainNode.connect(audioCtx.destination);
        });
    }

    setInterval(() => {
        const remainingTime = document.querySelector('.vjs-remaining-time-display').textContent;
        const h1 = document.querySelector('#vod_header > h1');
        var title = h1.textContent;
        document.title = `${remainingTime} ${title}`;
        if (remainingTime === "0:00") {
            playMelody();
            window.close();
        }
    }, 1000);

})();