Greasy Fork

Greasy Fork is available in English.

华为云课堂防止内存溢出

防止video.js刷新iframe导致内存溢出,增加判断登录是否过期。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         华为云课堂防止内存溢出
// @version      2.3.2
// @description  防止video.js刷新iframe导致内存溢出,增加判断登录是否过期。
// @author       LittleJake
// @license      Apache2.0
// @match        https://education.huaweicloud.com/courses/*
// @icon         https://www.google.cn/s2/favicons?domain=huaweicloud.com
// @grant        none
// @namespace http://greasyfork.icu/users/773473
// ==/UserScript==

(function() {
    'use strict';
    var rm = function(){
		//去除iframe
        if (document.getElementById("testIframe")){
            document.getElementById("testIframe").remove();
            console.log("rm success.");
        }
        //去除水印
        $('#watermark').val("False");
    };
	
	//处理登录失效问题
	if ($){
		let data_id = $(".vert-0").attr("data-id"),
			course_id = $(".vert-0").children().attr("data-course-id");
		let ajax_url = "https://education.huaweicloud.com/courses/" + course_id + "/xblock/" + data_id + "/handler/save_user_video_time";
		if (data_id && course_id){
			setInterval(function(){
				if ($){
					$.ajax({
						url: ajax_url,
						data: '{"msg":0,"type":""}',
						method: "POST",
						error: function(e){
							console.log(e.status);
							if (e.status == 403){
								window.location = "https://auth.huaweicloud.com/authui/login.html?service="+window.location;
								$ = null;
							}
						},
					});
				}
			}, 10000);
        }
		
		window.onload = rm;
        $("body").on('click', rm);
	}
	console.log("===华为云课堂增强脚本===");
	console.log("项目地址:https://github.com/LittleJake/education-huawei-memory-leak/");
	console.log("by LittleJake, licensed under Apache2.0");
})();