MediaWiki:Common.js:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
无编辑摘要
imported>=海豚=
无编辑摘要
(未显示2个用户的19个中间版本)
第1行: 第1行:
/* eslint-disable no-var */
/* eslint-disable no-magic-numbers */
/* global OO, mediaWiki, jQuery */
// <nowiki>
/* 这里的任何JavaScript将在全站加载
*  loader模块 写法参见 https://www.mediawiki.org/wiki/ResourceLoader/Modules#mw.loader.load
*/
"use strict";
(function($, mw) { //使用匿名函数防止污染顶级变量
   /* MediaViewer#populateStatsFromXhr 错误屏蔽 */
   (function() {
     var getResponseHeader = XMLHttpRequest.prototype.getResponseHeader;
     XMLHttpRequest.prototype.getResponseHeader = function(name) {
       return ("\n" + this.getAllResponseHeaders().toLowerCase()).includes("\n" + name.toLowerCase() + ": ") ? getResponseHeader.call(this, name) : (console.debug('Refused to get unsafe header "' + name + '"\n', this, "\n", new Error().stack), null);
     };
   })();
   //Extension:MultimediaViewer的半透明化修改。
   function multimediaViewer() {
     var _scrollTo = window.scrollTo;
     var flag = location.hash !== "";
     window.scrollTo = function scrollTo(x_option, y) {
       if (flag) {
         console.info("Prevent multimediaViewer called");
       } else {
         if (y === undefined) { _scrollTo(x_option); } else { _scrollTo(x_option, y); }
       }
     };
     setInterval(function() {
       $("a.image img[data-file-width], a.image img[data-file-height], .mw-mmv-filepage-buttons a.mw-mmv-view-expanded").not(".multimediaViewerScrollSet").each(function() {
         this.addEventListener("click", function(e) {
           if ($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]) {
             e.preventDefault();
             e.stopPropagation();
             e.stopImmediatePropagation();
             $($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]).click();
             return false;
           }
           flag = true;
         }, captureSupported ? {
           capture: true,
         } : true);
         $(this).addClass("multimediaViewerScrollSet");
       });
       if ($(".mw-mmv-close")[0]) {
         if (mw.config.get("wgMultimediaViewer") !== "on") {
           mw.config.set("wgMultimediaViewer", "on");
           $(".mw-mmv-image").off("click")[0].addEventListener("click", function(e) {
             if ($(e.target).is("img")) {
               window.open($(e.target).attr("src").replace(/(img\.moegirl\.org\/common\/)thumb\/([a-z\d]+\/[a-z\d]+\/)([^/]+)\/\d+px-\3/i, "$1$2$3"), "_blank").focus();
               e.preventDefault();
               e.stopPropagation();
               e.stopImmediatePropagation();
               return false;
             } else if ($(e.target).closest(".error-box")[0]) { return; }
             $(".mw-mmv-close").click();
           }, captureSupported ? {
             capture: true,
           } : true);
         }
       } else if (mw.config.get("wgMultimediaViewer") === "on") {
         flag = false;
         mw.config.set("wgMultimediaViewer", "off");
       }
     }, 137);
   }
   //子页面页顶链接
   function subpage_links() {
     var links = mw.config.get("wgPageName").split("/"),
       link = "",
       subpages = $(".subpages")[0] ? $(".subpages").remove().empty().text("<") : $('<span class="subpages"/>').text("<"),
       length = links.length - 1,
       index;
     if (mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) { links.splice(0, 1); }
     for (index = 0; index < length; index++) {
       link += "/" + links[index];
       subpages.append($("<a/>", {
         text: " " + links[index],
         href: link,
       }));
       if (length - index > 1) { subpages.append(" |"); }
     }
     if (subpages.find("a")[0]) { $("#contentSub").prepend(subpages); }
   }
    //跨站重定向页顶链接
    //跨站重定向页顶链接
    function crossDomain_link() {
    function crossDomain_link() {
第94行: 第11行:
      $("#contentSub").prepend(crossDomain);
      $("#contentSub").prepend(crossDomain);
    }
    }
   // 重复文件列表函数
/* Any JavaScript here will be loaded for all users on edit page load. */
   function duplicatedFileList() {
$(function() {
     if (window.location.href.indexOf("title") === -1) { window.location.replace("http://www.hmoegirl.com/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0"); }
   var wpSummary = $('[name="wpSummary"]');
     $("#mw-content-text .mw-spcontent ol").attr("id",
   // $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width());
       "picOl");
   $(".mw-summary-preset-item a").on("click", function() {
      $("#picOl").before('<p id="picOlTitle">图片列表:</p>').after('<p id="MP3OlTitle">MP3列表:</p><ol start="1" id="MP3Ol"></ol>');
      wpSummary.val(wpSummary.val() + " " + $(this).text());
      $("#picOlTitle, #MP3OlTitle").hide();
      wpSummary.focus();
      $("#picOl").find("[href$='.mp3'], [href$='.ogg']").parent().appendTo("#MP3Ol");
      return false;
     if ($("#picOl").find("li").length) { $("#picOlTitle").show(); }
   });
      if ($("#MP3Ol").find("li").length) { $("#MP3OlTitle").show(); }
 
      $(".mw-spcontent > p:nth-child(1), .mw-spcontent > p:nth-child(2), .mw-spcontent > p:nth-child(7)").hide();
   // .wikiEditor-ui-controls 颜色修正
   $('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color'));
 
   //编辑提示检查
   if ($(".mw-summary-preset")[0]) {
     $(".CheckNewSectionOn").hide();
   } else {
      $(".CheckNewSectionOff").hide();
      $('.headerInputbox a[href*="preload=Template%3A权限申请%2F"]').attr("target", "_self");
    }
    }
   //编辑请求
 
    function editRequest() {
    if ($(".AbusefilterWarningNoHttp")[0]) {
     var nsIds = mw.config.get("wgNamespaceIds"),
      $("#wpTextbox1").val($("#wpTextbox1").val().replace(/http:\/\/([a-z\d]+\.bilibili\.[a-z\d]+)/ig, "https://$1"));
       nsId = mw.config.get("wgNamespaceNumber"),
       ns = [];
     for (var i in nsIds) {
       if (nsIds[i] === nsId) { ns.push(i); }
     }
     if (!ns[0]) { return; }
     var page = mw.config.get("wgPageName"),
       talkns;
     for (var j = 0, l = ns.length; j < l; j++) {
       if (/^[A-Za-z0-9]+[ _]talk$/i.test(ns[j])) { return; }
       if (/^[a-zA-Z0-9]+$/.test(ns[j])) { talkns = ns[j] + "_talk:"; }
       page = page.replace(new RegExp("^" + ns[j] + ":", "i"), "");
     }
      var talkpage = talkns + page;
     var container = $("<div/>", {
       "class": "editRequest",
     });
     container.append("您虽然无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
     $("<span/>").addClass("newComment").text("提出编辑请求").on("click", function() {
       window.open("https://www.hmoegirl.com/index.php?action=edit&preload=Template:编辑请求/comment&preloadtitle=编辑请求 - " + mw.config.get("wgUserName") + "&section=new&title=" + talkpage, "_blank");
     }).appendTo(container);
     $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
   }
   //防滥用即将删除模板
   function antiAbuseListener(textarea, event) {
     var filters = [
       "{{即将删除",
       "{{即將刪除",
       "{{挂删",
       "{{模板:即将删除",
       "{{模板:即將刪除",
       "{{template:即将删除",
       "{{template:即將刪除",
       "[[分类:即将删除的页面",
       "[[分類:即將刪除的頁面",
       "[[category:即将删除的页面",
       "[[category:即將刪除的頁面",
       "{{文件转移到萌娘共享",
       "{{文件轉移到萌娘共享",
       "{{模板:文件转移到萌娘共享",
       "{{模板:文件轉移到萌娘共享",
       "{{template:文件转移到萌娘共享",
       "{{template:文件轉移到萌娘共享",
       "[[分类:需要删除执行员删除的页面",
       "[[分類:需要刪除執行員刪除的頁面",
       "[[category:需要删除执行员删除的页面",
       "[[category:需要刪除執行員刪除的頁面",
     ];
     var text1 = textarea.value;
     text1 = text1.replace(/<\/?(?:nowiki|noinclude)>/g, "");
     text1 = text1.replace(/<(onlyinclude|includeonly)>.*?<\/\1>/g, "");
     var text2 = textarea.value;
     text2 = text2.replace(/<\/?(?:onlyinclude|includeonly)>/g, "");
     text2 = text2.replace(/<(nowiki|noinclude)>.*?<\/\1>/g, "");
     var results = [];
     for (var i = 0, l = filters.length; i < l; i++) {
       var regExp = new RegExp(filters[i].replace(/\[/g, "\\["), "i");
       if (regExp.test(text1) || regExp.test(text2)) { results.push(filters[i]); }
     }
     if (results.length > 0) {
       var messageDialog = new OO.ui.MessageDialog();
       var windowManager = new OO.ui.WindowManager();
       $("body").append(windowManager.$element);
       windowManager.addWindows([messageDialog]);
       messageDialog.title.$label.html("H萌娘提醒您<br>您的编辑包含禁止内容!");
       messageDialog.message.$label.html("<br>您提交的内容包含以下部分,被禁止提交:<br><br><ul>" + results.map(function(result) {
         return "<li>" + result + "</li>";
       }).join("") + '</ul><br><br>如果您认为您的编辑无误,请在自行保存编辑内容后到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="https://www.hmoegirl.com/Talk:讨论版">讨论版</a>提问。');
       windowManager.openWindow(messageDialog, {
         actions: [{
           action: "accept",
           label: "我知道了",
           flags: "primary",
         }],
       });
       event.preventDefault();
       event.stopImmediatePropagation();
       event.stopPropagation();
       return false;
     }
    }
    }


    function antiAbuse(textarea, submitButton, form) {
    // Customized File Insertion dialog
     mw.loader.using(["oojs-ui"]).then(function() {
   // Copyright 2017 The Little Moe New LLC. All rights reserved.
       if (submitButton) {
   mw.loader.using(["oojs", "oojs-ui"]).then(function() {
         submitButton.addEventListener("click", function(e) {
     $("#wpTextbox1").on("wikiEditor-toolbar-doneInitialSections", function() {
           antiAbuseListener(textarea, e);
       function FileInsertionDialog(config) {
          }, captureSupported ? {
          FileInsertionDialog.super.call(this, config);
           capture: true,
         } : true);
        }
        }
        if (form) {
        OO.inheritClass(FileInsertionDialog, OO.ui.ProcessDialog);
          form.addEventListener("submit", function(e) {
       // Name
            antiAbuseListener(textarea, e);
       FileInsertionDialog.static.name = "fileInsertionDialog";
          }, captureSupported ? {
       FileInsertionDialog.static.title = mw.msg("wikieditor-toolbar-tool-file-title");
            capture: true,
       FileInsertionDialog.static.actions = [{
          } : true);
          flags: "primary",
       }
         label: mw.msg("wikieditor-toolbar-tool-file-insert"),
     });
         action: "insert"
   }
       }, {
   /* 函数执行体 */
         flags: "safe",
   $(function() {
         label: mw.msg("wikieditor-toolbar-tool-file-cancel")
     //Template:heimu在safari上的暴力workaround
       }];
     mw.loader.using("jquery.client", function() {
       // Initialization
       if ($.client.profile().name === "safari") {
       FileInsertionDialog.prototype.initialize = function() {
          $(".heimu").on("click", function() {
         FileInsertionDialog.super.prototype.initialize.call(this);
            $(this).toggleClass("off");
         this.panel = new OO.ui.PanelLayout({
           padded: true,
            expanded: false
         });
         this.fileMetaContent = new OO.ui.FieldsetLayout();
         this.alignmentContent = new OO.ui.FieldsetLayout();
         this.formatContent = new OO.ui.FieldsetLayout();
         this.fileNameInput = new OO.ui.TextInputWidget({
           indicator: "required"
          });
         this.fileNameField = new OO.ui.FieldLayout(this.fileNameInput, {
            label: mw.msg("wikieditor-toolbar-file-target"),
           align: "top"
          });
         this.fileTitleInput = new OO.ui.TextInputWidget();
         this.fileTitleField = new OO.ui.FieldLayout(this.fileTitleInput, {
           label: mw.msg("wikieditor-toolbar-file-caption"),
           align: "top"
         });
         this.sizeInput = new OO.ui.TextInputWidget();
         this.sizeField = new OO.ui.FieldLayout(this.sizeInput, {
           label: mw.msg("wikieditor-toolbar-file-size"),
           align: "top"
         });
         this.fileMetaContent.addItems([this.fileNameField, this.fileTitleField, this.sizeField]);
         var alignOptionDefault = new OO.ui.ButtonOptionWidget({
           data: "default",
           label: mw.msg("wikieditor-toolbar-file-default"),
           title: mw.msg("wikieditor-toolbar-file-default")
         });
         var alignOptionNone = new OO.ui.ButtonOptionWidget({
           data: "none",
           label: mw.msg("wikieditor-toolbar-file-format-none"),
           title: mw.msg("wikieditor-toolbar-file-format-none")
         });
         var magicWords = mw.config.get("wgWikiEditorMagicWords");
         var alignOptionMid = new OO.ui.ButtonOptionWidget({
           data: "center",
           label: magicWords.img_center,
           title: magicWords.img_center
         });
         var alignOptionLeft = new OO.ui.ButtonOptionWidget({
           data: "left",
           label: magicWords.img_left,
           title: magicWords.img_left
         });
         var alignOptionRight = new OO.ui.ButtonOptionWidget({
           data: "right",
           label: magicWords.img_right,
           title: magicWords.img_right
         });
         this.alignmentSelect = new OO.ui.ButtonSelectWidget({
           items: [alignOptionNone, alignOptionDefault, alignOptionMid, alignOptionLeft, alignOptionRight]
         });
         this.alignmentField = new OO.ui.FieldLayout(this.alignmentSelect, {
           label: mw.msg("wikieditor-toolbar-file-float"),
           align: "top"
         });
         this.alignmentContent.addItems([this.alignmentField]);
         var formatOptionThumbnail = new OO.ui.ButtonOptionWidget({
           data: "thumbnail",
           label: magicWords.img_thumbnail,
           title: magicWords.img_thumbnail
         });
         var formatOptionFramed = new OO.ui.ButtonOptionWidget({
           data: "framed",
           label: magicWords.img_framed,
           title: magicWords.img_framed
         });
          var formatOptionFrameless = new OO.ui.ButtonOptionWidget({
           data: "frameless",
           label: magicWords.img_frameless,
           title: magicWords.img_frameless
         });
         var formatOptionNone = new OO.ui.ButtonOptionWidget({
           data: "default",
           label: magicWords.img_none,
           title: magicWords.img_none
         });
         this.formatSelect = new OO.ui.ButtonSelectWidget({
           items: [formatOptionThumbnail, formatOptionFramed, formatOptionFrameless, formatOptionNone]
         });
         this.formatField = new OO.ui.FieldLayout(this.formatSelect, {
            label: mw.msg("wikieditor-toolbar-file-format"),
           align: "top"
         });
         this.formatContent.addItems([this.formatField]);
         this.panel.$element.append(this.fileMetaContent.$element);
         this.panel.$element.append(this.alignmentContent.$element);
         this.panel.$element.append(this.formatContent.$element);
         this.$body.append(this.panel.$element);
         this.fileNameInput.connect(this, {
           change: "onFileNameChange"
         });
       };
       // Specify the dialog height (or don"t to use the automatically generated height).
       FileInsertionDialog.prototype.getBodyHeight = function() {
         return this.panel.$element.outerHeight(true);
       };
       // Name validation
       FileInsertionDialog.prototype.onFileNameChange = function(value) {
         this.actions.setAbilities({
           insert: !!value.length
          });
          });
        }
        };
     });
       // Default state initialization
     //Extension:MultimediaViewer的半透明化修改
       FileInsertionDialog.prototype.getSetupProcess = function(data) {
     if ($("img[srcset][data-file-width][data-file-height]")[0]) { multimediaViewer(); }
         data = data || {};
     // Add "mainpage" class to the body element
         return FileInsertionDialog.super.prototype.getSetupProcess.call(this, data).next(function() {
     if (mw.config.get("wgMainPageTitle") === mw.config.get("wgPageName") && mw.config.get("wgAction") === "view") { $("body").addClass("mainpage"); }
           this.actions.setAbilities({
     //重复文件列表区分图片和音频
             insert: false
     if ($(".mw-special-ListDuplicatedFiles").length && $(".mw-spcontent > p").length > 1) { duplicatedFileList(); }
           });
     //需要时载入对应的 scripts
           this.fileNameInput.setValue("");
     if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Search") { mw.loader.load("/index.php?title=MediaWiki:Common.js/edit.js&action=raw&ctype=text/javascript"); }
           this.fileTitleInput.setValue("");
     //子页面页顶链接
           this.sizeInput.setValue("");
     if (mw.config.get("wgPageName").indexOf("/") !== -1 && (mw.config.get("wgNamespaceIds").special !== mw.config.get("wgNamespaceNumber") || mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) && !window._unsubpage) { subpage_links(); }
           this.alignmentSelect.selectItemByData("default");
     // 跨站重定向页顶链接
           this.formatSelect.selectItemByData("thumbnail");
     mw.loader.using("mediawiki.Uri").then(function() {
         }, this);
       if (new mw.Uri().query.rdfrom && new mw.Uri(new mw.Uri().query.rdfrom).query.title && new mw.Uri(new mw.Uri().query.rdfrom).query.redirect === "no") { crossDomain_link(); }
       };
     });
       // Context setup
     // 编辑请求
       FileInsertionDialog.prototype.setContext = function(context) {
     if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
         this.editorContext = context;
     //修复代码编辑器$.ucFirst引用错误
       };
     $.extend({
       // Specify processes to handle the actions.
       ucFirst: function(_s) {
       FileInsertionDialog.prototype.getActionProcess = function(action) {
         var s = _s + "";
         if (action === "insert") {
         return s.charAt(0).toUpperCase() + s.substring(1);
           return new OO.ui.Process(function() {
       },
             this.insertImage();
     });
           }, this);
     // 注释内列表
         }
     $(".reference-text > ul,.reference-text > ol").each(function() {
         // Fallback to parent handler
       if (this.parentElement.childNodes[0] === this) { $(this).addClass("listInRef"); }
         return FileInsertionDialog.super.prototype.getActionProcess.call(this, action);
     });
       };
     // 列表侧边距
       // Handles image insertion.
     setInterval(function() {
        FileInsertionDialog.prototype.insertImage = function() {
        $(".mw-parser-output ul, .mw-parser-output ol").not(".margin-left-set").each(function() {
          if (!this.editorContext) return;
          if (/none.+none/i.test($(this).css("list-style")) || $(this).is(".gallery")) {
         var fileName, caption, fileFloat, fileFormat, fileSize, fileTitle, options, fileUse, hasPxRgx = /.+px$/,
           if ($(this).parent().is("li") && $(this).parent().parent().is("ul,ol")) { $(this).css("margin-left", "1.2em"); } else { $(this).css("margin-left", "0.2em"); }
            magicWordsI18N = mw.config.get("wgWikiEditorMagicWords");
         } else if ($(this).is("ol")) {
         fileName = this.fileNameInput.getValue();
            var l = $(this).children("li").length;
         caption = this.fileTitleInput.getValue();
           if ($(this).attr("start")) { l += parseInt($(this).attr("start")); }
          fileSize = this.sizeInput.getValue();
           $(this).css("margin-left", (l + "").length * 0.5 + 1.2 + "em");
          fileFloat = this.alignmentSelect.getSelectedItem().data;
          } else { $(this).css("margin-left", "1.2em"); }
          fileFormat = this.formatSelect.getSelectedItem().data;
          $(this).addClass("margin-left-set");
          // Append px to end to size if not already contains it
       });
         if (fileSize !== "" && !hasPxRgx.test(fileSize)) {
     }, 200);
            fileSize += "px";
     //修正hash跳转错误
         }
     if ($(".mw-collapsible")[0]) {
         if (fileName !== "") {
       mw.loader.using("jquery.makeCollapsible", function() {
           fileTitle = new mw.Title(fileName);
          $(".mw-collapsible").makeCollapsible();
           // Append file namespace prefix to filename if not already contains it
         var hash = location.hash;
           if (fileTitle.getNamespaceId() !== 6) {
         location.hash = "";
             fileTitle = new mw.Title(fileName, 6);
          location.hash = hash;
       });
     }
     // 防滥用即将删除
     if (!mw.config.get("wgUserGroups").includes("sysop") && !mw.config.get("wgUserGroups").includes("patroller")) {
       setInterval(function() {
         if ($(".Wikiplus-InterBox")[0]) {
            var targetBox = $(".Wikiplus-InterBox");
           if (targetBox.data("isTrusted") !== true) {
             targetBox.data("isTrusted", true);
             targetBox.css("z-index", 100);
             antiAbuse($("#Wikiplus-Quickedit")[0], $("#Wikiplus-Quickedit-Submit")[0], undefined);
             var events = $._data($("#Wikiplus-Quickedit")[0], "events");
             if (events && events.keydown) {
               events.keydown.sort(function(a, b) {
                 return a.guid - b.guid;
               });
               events.keydown[0].handler = function(e) {
                 if (e.ctrlKey && e.which === 83) {
                   if (e.shiftKey) {
                     $("#Wikiplus-Quickedit-MinorEdit").click();
                   }
                   if (antiAbuseListener($("#Wikiplus-Quickedit")[0], e) !== false) {
                     $("#Wikiplus-Quickedit-Submit").click();
                     e.preventDefault();
                     e.stopPropagation();
                   }
                 }
               };
             }
            }
            }
           fileName = fileTitle.toText();
          }
          }
          if ($("form#editform")[0]) {
          options = [fileSize, fileFormat, fileFloat];
            var targetForm = $("form#editform");
         // Filter empty values
           if (targetForm.data("isTrusted") !== true) {
         options = $.grep(options, function(val) {
             targetForm.data("isTrusted", true);
            return val.length && val !== "default";
             antiAbuse($("#wpTextbox1")[0], $("#wpSave")[0], targetForm[0]);
         });
         if (caption.length) {
           options.push(caption);
         }
         fileUse = options.length === 0 ? fileName : fileName + "|" + options.join("|");
         $.wikiEditor.modules.toolbar.fn.doAction(this.editorContext, {
           type: "replace",
           options: {
             pre: "[[",
             peri: fileUse,
             post: "]]",
             ownline: true
            }
            }
         }
       }, 1000);
     }
   //R18警告
   function r18Warning() {
     var content = $('<div id="x18"><div id="x18Context"><div id="x18Title"><div id="x18Icon"></div></div><div class="x18Button"></div></div></div>');
     if (!window.localStorage.getItem('x18')) { //如果没有x18记录
       $('body').css('overflow', 'hidden'); //禁止滚屏
       $('#mw-content-text').css({
         'opacity': 0
       });
   //禁止偷看
       content.prependTo('body').find('.x18Button').append('<div id="x18Yes">是</div><div id="x18No" class="x18Button">否</div>')
         .end().find('#x18Title').append('你是否已年满十八岁?')
         .end().delay(400).queue(function() {
           $(this).css({
             'opacity': 1
           }); //显示警告信息
           $(this).dequeue();
          });
          });
       $('#x18Yes').on('click', function() {
          this.close();
         window.localStorage.setItem('x18', true); //记录x18
        };
         $('#mw-content-text').css('opacity', 1).removeAttr('style'); //显示内容
      });
          $("#x18").remove(); //移除警告信息
         $('body').removeAttr('style'); //允许滚屏
        });
       $('#x18No').on('click', function() {
         window.location.replace(window.location.origin + '/' + mw.config.get('wgMainPageTitle')); //不给你看
       });
      } else $("#x18").remove(); //如果有x18记录
   }
   $(function() {
     tabs();
     r18Warning();
    });
    });
})();
});
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量以防止冲突
// </nowiki>

2020年6月15日 (一) 16:51的版本

    //跨站重定向页顶链接
    function crossDomain_link() {
        var url = new mw.Uri(new mw.Uri().query.rdfrom);
        var link = url.query.title;
        var domain = url.host;
        var crossDomain = $("<div/>");
        var anchor = $("<a/>");
        crossDomain.text("<");
        anchor.attr("href", url + "").text(link + "【来自 " + domain + "】");
        crossDomain.append(anchor);
        $("#contentSub").prepend(crossDomain);
    }
/* Any JavaScript here will be loaded for all users on edit page load. */
$(function() {
    var wpSummary = $('[name="wpSummary"]');
    // $(".mw-summary-preset-item a").closest('.oo-ui-fieldLayout-header').width($('#wpSummary').width());
    $(".mw-summary-preset-item a").on("click", function() {
        wpSummary.val(wpSummary.val() + " " + $(this).text());
        wpSummary.focus();
        return false;
    });

    // .wikiEditor-ui-controls 颜色修正
    $('.wikiEditor-ui-controls').css('background-color', $('#content').css('background-color'));

    //编辑提示检查
    if ($(".mw-summary-preset")[0]) {
        $(".CheckNewSectionOn").hide();
    } else {
        $(".CheckNewSectionOff").hide();
        $('.headerInputbox a[href*="preload=Template%3A权限申请%2F"]').attr("target", "_self");
    }

    if ($(".AbusefilterWarningNoHttp")[0]) {
        $("#wpTextbox1").val($("#wpTextbox1").val().replace(/http:\/\/([a-z\d]+\.bilibili\.[a-z\d]+)/ig, "https://$1"));
    }

    // Customized File Insertion dialog
    // Copyright 2017 The Little Moe New LLC. All rights reserved.
    mw.loader.using(["oojs", "oojs-ui"]).then(function() {
        $("#wpTextbox1").on("wikiEditor-toolbar-doneInitialSections", function() {
            function FileInsertionDialog(config) {
                FileInsertionDialog.super.call(this, config);
            }
            OO.inheritClass(FileInsertionDialog, OO.ui.ProcessDialog);
            // Name
            FileInsertionDialog.static.name = "fileInsertionDialog";
            FileInsertionDialog.static.title = mw.msg("wikieditor-toolbar-tool-file-title");
            FileInsertionDialog.static.actions = [{
                flags: "primary",
                label: mw.msg("wikieditor-toolbar-tool-file-insert"),
                action: "insert"
            }, {
                flags: "safe",
                label: mw.msg("wikieditor-toolbar-tool-file-cancel")
            }];
            // Initialization
            FileInsertionDialog.prototype.initialize = function() {
                FileInsertionDialog.super.prototype.initialize.call(this);
                this.panel = new OO.ui.PanelLayout({
                    padded: true,
                    expanded: false
                });
                this.fileMetaContent = new OO.ui.FieldsetLayout();
                this.alignmentContent = new OO.ui.FieldsetLayout();
                this.formatContent = new OO.ui.FieldsetLayout();
                this.fileNameInput = new OO.ui.TextInputWidget({
                    indicator: "required"
                });
                this.fileNameField = new OO.ui.FieldLayout(this.fileNameInput, {
                    label: mw.msg("wikieditor-toolbar-file-target"),
                    align: "top"
                });
                this.fileTitleInput = new OO.ui.TextInputWidget();
                this.fileTitleField = new OO.ui.FieldLayout(this.fileTitleInput, {
                    label: mw.msg("wikieditor-toolbar-file-caption"),
                    align: "top"
                });
                this.sizeInput = new OO.ui.TextInputWidget();
                this.sizeField = new OO.ui.FieldLayout(this.sizeInput, {
                    label: mw.msg("wikieditor-toolbar-file-size"),
                    align: "top"
                });
                this.fileMetaContent.addItems([this.fileNameField, this.fileTitleField, this.sizeField]);
                var alignOptionDefault = new OO.ui.ButtonOptionWidget({
                    data: "default",
                    label: mw.msg("wikieditor-toolbar-file-default"),
                    title: mw.msg("wikieditor-toolbar-file-default")
                });
                var alignOptionNone = new OO.ui.ButtonOptionWidget({
                    data: "none",
                    label: mw.msg("wikieditor-toolbar-file-format-none"),
                    title: mw.msg("wikieditor-toolbar-file-format-none")
                });
                var magicWords = mw.config.get("wgWikiEditorMagicWords");
                var alignOptionMid = new OO.ui.ButtonOptionWidget({
                    data: "center",
                    label: magicWords.img_center,
                    title: magicWords.img_center
                });
                var alignOptionLeft = new OO.ui.ButtonOptionWidget({
                    data: "left",
                    label: magicWords.img_left,
                    title: magicWords.img_left
                });
                var alignOptionRight = new OO.ui.ButtonOptionWidget({
                    data: "right",
                    label: magicWords.img_right,
                    title: magicWords.img_right
                });
                this.alignmentSelect = new OO.ui.ButtonSelectWidget({
                    items: [alignOptionNone, alignOptionDefault, alignOptionMid, alignOptionLeft, alignOptionRight]
                });
                this.alignmentField = new OO.ui.FieldLayout(this.alignmentSelect, {
                    label: mw.msg("wikieditor-toolbar-file-float"),
                    align: "top"
                });
                this.alignmentContent.addItems([this.alignmentField]);
                var formatOptionThumbnail = new OO.ui.ButtonOptionWidget({
                    data: "thumbnail",
                    label: magicWords.img_thumbnail,
                    title: magicWords.img_thumbnail
                });
                var formatOptionFramed = new OO.ui.ButtonOptionWidget({
                    data: "framed",
                    label: magicWords.img_framed,
                    title: magicWords.img_framed
                });
                var formatOptionFrameless = new OO.ui.ButtonOptionWidget({
                    data: "frameless",
                    label: magicWords.img_frameless,
                    title: magicWords.img_frameless
                });
                var formatOptionNone = new OO.ui.ButtonOptionWidget({
                    data: "default",
                    label: magicWords.img_none,
                    title: magicWords.img_none
                });
                this.formatSelect = new OO.ui.ButtonSelectWidget({
                    items: [formatOptionThumbnail, formatOptionFramed, formatOptionFrameless, formatOptionNone]
                });
                this.formatField = new OO.ui.FieldLayout(this.formatSelect, {
                    label: mw.msg("wikieditor-toolbar-file-format"),
                    align: "top"
                });
                this.formatContent.addItems([this.formatField]);
                this.panel.$element.append(this.fileMetaContent.$element);
                this.panel.$element.append(this.alignmentContent.$element);
                this.panel.$element.append(this.formatContent.$element);
                this.$body.append(this.panel.$element);
                this.fileNameInput.connect(this, {
                    change: "onFileNameChange"
                });
            };
            // Specify the dialog height (or don"t to use the automatically generated height).
            FileInsertionDialog.prototype.getBodyHeight = function() {
                return this.panel.$element.outerHeight(true);
            };
            // Name validation
            FileInsertionDialog.prototype.onFileNameChange = function(value) {
                this.actions.setAbilities({
                    insert: !!value.length
                });
            };
            // Default state initialization
            FileInsertionDialog.prototype.getSetupProcess = function(data) {
                data = data || {};
                return FileInsertionDialog.super.prototype.getSetupProcess.call(this, data).next(function() {
                    this.actions.setAbilities({
                        insert: false
                    });
                    this.fileNameInput.setValue("");
                    this.fileTitleInput.setValue("");
                    this.sizeInput.setValue("");
                    this.alignmentSelect.selectItemByData("default");
                    this.formatSelect.selectItemByData("thumbnail");
                }, this);
            };
            // Context setup
            FileInsertionDialog.prototype.setContext = function(context) {
                this.editorContext = context;
            };
            // Specify processes to handle the actions.
            FileInsertionDialog.prototype.getActionProcess = function(action) {
                if (action === "insert") {
                    return new OO.ui.Process(function() {
                        this.insertImage();
                    }, this);
                }
                // Fallback to parent handler
                return FileInsertionDialog.super.prototype.getActionProcess.call(this, action);
            };
            // Handles image insertion.
            FileInsertionDialog.prototype.insertImage = function() {
                if (!this.editorContext) return;
                var fileName, caption, fileFloat, fileFormat, fileSize, fileTitle, options, fileUse, hasPxRgx = /.+px$/,
                    magicWordsI18N = mw.config.get("wgWikiEditorMagicWords");
                fileName = this.fileNameInput.getValue();
                caption = this.fileTitleInput.getValue();
                fileSize = this.sizeInput.getValue();
                fileFloat = this.alignmentSelect.getSelectedItem().data;
                fileFormat = this.formatSelect.getSelectedItem().data;
                // Append px to end to size if not already contains it
                if (fileSize !== "" && !hasPxRgx.test(fileSize)) {
                    fileSize += "px";
                }
                if (fileName !== "") {
                    fileTitle = new mw.Title(fileName);
                    // Append file namespace prefix to filename if not already contains it
                    if (fileTitle.getNamespaceId() !== 6) {
                        fileTitle = new mw.Title(fileName, 6);
                    }
                    fileName = fileTitle.toText();
                }
                options = [fileSize, fileFormat, fileFloat];
                // Filter empty values
                options = $.grep(options, function(val) {
                    return val.length && val !== "default";
                });
                if (caption.length) {
                    options.push(caption);
                }
                fileUse = options.length === 0 ? fileName : fileName + "|" + options.join("|");
                $.wikiEditor.modules.toolbar.fn.doAction(this.editorContext, {
                    type: "replace",
                    options: {
                        pre: "[[",
                        peri: fileUse,
                        post: "]]",
                        ownline: true
                    }
                });
                this.close();
            };
        });
    });
});