MediaWiki:Common.js:修订间差异

imported>=海豚=
与萌百同步
imported>=海豚=
无编辑摘要
第10行: 第10行:
"use strict";
"use strict";
(function($, mw) { //使用匿名函数防止污染顶级变量
(function($, mw) { //使用匿名函数防止污染顶级变量
    /* 反嵌入反反代 */
    try {
        var substHost;
        try {
            substHost = top.location.host;
        } catch (_) {
            substHost = "";
        }
        var currentHostFlag = !/\.moegirl\.org$/i.test(location.host);
        if (top !== window || currentHostFlag) {
            var reverseProxyhostAlerted = [];
            if (sessionStorage.getItem("reverse proxy alerted") !== null) {
                try {
                    reverseProxyhostAlerted = JSON.parse(sessionStorage.getItem("reverse proxy alerted"));
                    if (!Array.isArray(reverseProxyhostAlerted)) { reverseProxyhostAlerted = []; }
                } catch (e) {
                    reverseProxyhostAlerted = [];
                }
            }
            var detectHost = currentHostFlag ? location.host : substHost;
            if (!reverseProxyhostAlerted.includes(detectHost)) {
                reverseProxyhostAlerted.push(detectHost);
                mw.loader.using(["oojs-ui"]).then(function() {
                    var messageDialog = new OO.ui.MessageDialog();
                    var windowManager = new OO.ui.WindowManager();
                    $("body").append(windowManager.$element);
                    windowManager.addWindows([messageDialog]);
                    messageDialog.title.$label.html("萌娘百科提醒您<br>您当前是在" + (currentHostFlag ? "非萌百域名" : "嵌套窗口") + "访问");
                    messageDialog.message.$label.html("<p>请注意不要在此域名下输入您的用户名或密码,以策安全!</p><p>" + (detectHost ? (currentHostFlag ? "当前" : "顶层窗口") + "域名为 " + location.host + ",<br>" : "") + "萌百域名是以 .moegirl.org 结尾的。</p>");
                    windowManager.openWindow(messageDialog, {
                        actions: [{
                            action: 'accept',
                            label: '我知道了',
                            flags: 'primary'
                        }]
                    });
                });
            }
            sessionStorage.setItem("reverse proxy alerted", JSON.stringify(reverseProxyhostAlerted));
        }
    } catch (e) {
        console.debug(e);
    }
    /* capture支持检测 */
    var captureSupported = false;
    try {
        var options = Object.defineProperty({}, "capture", {
            get: function() {
                captureSupported = true;
                return true;
            },
        });
        window.addEventListener("test", null, options);
    } catch (err) { /* */ }
     /* 函数定义体 */
     /* 函数定义体 */
     //滚动公告
     //滚动公告
第331行: 第277行:
         });
         });
         //编辑请求
         //编辑请求
         if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
         if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
         //修复代码编辑器$.ucFirst引用错误
         //修复代码编辑器$.ucFirst引用错误
         $.extend({
         $.extend({