YunTech EClass 破解

YunTech EClass,全螢幕事件攔截+XHR請求攔截+教材允許下載&快進

目前為 2021-11-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YunTech EClass 破解
// @namespace    Anonymous3356@TW
// @version      0.3
// @description  YunTech EClass,全螢幕事件攔截+XHR請求攔截+教材允許下載&快進
// @author       Anonymous Jerry
// @match        https://eclass.yuntech.edu.tw/*
// @run-at		 document-start
// @require      https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 攔截離開頁面事件
    Window.prototype._addEventListener = Window.prototype.addEventListener;
    Window.prototype.addEventListener = function (eventName, fn, options) {
        if (eventName === 'blur' || eventName === 'pagehide') {
            console.log(`已攔截${eventName}事件!`);
            return;
        }
        // console.log(`Window ${eventName}事件!`);

        this._addEventListener(eventName, fn, options);
    };

    // 攔截全螢幕事件
    Document.prototype._addEventListener = Document.prototype.addEventListener;
    Document.prototype.addEventListener = function (eventName, fn, options) {
        if (eventName === 'fullscreenchange'
            || eventName === 'mozfullscreenchange'
            || eventName === 'webkitfullscreenchange'
            || eventName === 'MSFullscreenChange') {
            console.log(`已攔截${eventName}事件!`);
            return;
        }
        // console.log(`Document ${eventName}事件!`);

        this._addEventListener(eventName, fn, options);
    };

    function hookGetter(v,xhr){
        if (xhr.responseURL.indexOf('https://eclass.yuntech.edu.tw/api/exams/') > -1) {
            var json = JSON.parse(v);
            if (json.hasOwnProperty('enable_anti_cheat') && json.enable_anti_cheat === true) {
                json.enable_anti_cheat = false;
                console.log('enable_anti_cheat = false');
            }
            if (json.hasOwnProperty('is_leaving_window_constrained') && json.is_leaving_window_constrained === true) {
                json.is_leaving_window_constrained = false;
                console.log('is_leaving_window_constrained  = false');
            }
            // console.log(JSON.stringify(json));
            return JSON.stringify(json);
        }
        else if (xhr.responseURL.indexOf('https://eclass.yuntech.edu.tw/api/course/') > -1) {
            json = JSON.parse(v);
            if (json.hasOwnProperty('enable_anti_cheat') && json.enable_anti_cheat === true) {
                json.enable_anti_cheat = false;
                console.log('enable_anti_cheat = false');
            }
            if (json.hasOwnProperty('is_leaving_window_constrained') && json.is_leaving_window_constrained === true) {
                json.is_leaving_window_constrained = false;
                console.log('is_leaving_window_constrained = false');
            }
            // console.log(JSON.stringify(json));
            return JSON.stringify(json);
        }
        else if (xhr.responseURL.indexOf('https://eclass.yuntech.edu.tw/api/activities/') > -1) {
            // console.log('Into activities');
            // 教材影片允許下載&快進
            var obj = JSON.parse(v, (key, value) => (key == 'allow_forward_seeking' && value == false ? true :value) ||
                                 (key == 'allow_download' && value == false ? true :value))
            console.log('allow_download & allow_forward_seeking = true');
            return JSON.stringify(obj);
        }
        else return v;
    }

    // hook response的getter
    ah.hook({
        responseText: {
            getter:hookGetter
        },
        response: {
            getter:hookGetter
        }
    });
})();