Greasy Fork

Greasy Fork is available in English.

广州大学第二课堂系统弹出窗口兼容

为广州大学第二课堂系统中使用的 showModalDialog 函数作兼容处理

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         广州大学第二课堂系统弹出窗口兼容
// @namespace    http://greasyfork.icu/zh-CN/users/220174-linepro
// @version      1.1
// @description  为广州大学第二课堂系统中使用的 showModalDialog 函数作兼容处理
// @author       LinePro
// @match        *://172.17.1.123/*
// @match        *://webvpn.gzhu.edu.cn/http/*/XS/XMSB.aspx
// @match        *://webvpn.gzhu.edu.cn/http/*/JWC/view.aspx
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    function getValue(str, key) {
        const index = str.indexOf(key);
        return str.slice(index + key.length + 1, str.indexOf(';', index));
    }
    window.showModalDialog = function (uri, _arguments, _options) {
        _options = _options.toLowerCase();
        let windowFeature = 'toolbar=no, menubar=no';
        const dialogWidth = getValue(_options, 'dialogwidth');
        const dialogHeight = getValue(_options, 'dialogheight');
        if (dialogWidth)
            windowFeature += ', width=' + dialogWidth;
        if (dialogHeight)
            windowFeature += ', height=' + dialogHeight;
        window.open(uri, "_blank", windowFeature);
    }
})();