“MediaWiki:Common.js”的版本间的差异

来自萌娘共享
跳转至: 导航搜索
第21行: 第21行:
 
         if ($("#MP3Ol").find("li").length) $("#MP3OlTitle").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();
 
         $(".mw-spcontent > p:nth-child(1), .mw-spcontent > p:nth-child(2), .mw-spcontent > p:nth-child(7)").hide();
 +
        if (mw.config.get('wgUserGroups').indexOf('sysop') !== -1) {
 +
            if (mw.config.get('mgDuplicateFilesClean')) mw.config.get('mgDuplicateFilesClean')();
 +
            else mw.config.set('mgDuplicateFilesClean', true);
 +
        }
 
     }
 
     }
 
     $(window).on('load', function() {
 
     $(window).on('load', function() {

2017年6月19日 (一) 02:26的版本

/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
$(function() {
    if (new mw.Uri(document.referrer).host === "zh.moegirl.org") $("#back").removeAttr('style').on("click", function() {
        history.go(-1);
    });
    if ($(".fileInfo")[0]) $(window).on('load', function() {
        $(".mw-ui-button-group.mw-mmv-filepage-buttons:first").prepend($("<a/>", {
            class: "mw-mmv-view-expanded mw-ui-button mw-ui-icon",
            text: "在萌娘百科上查看文件说明页"
        }).on("click", function() {
            window.open("https://zh.moegirl.org" + location.pathname + location.search, "_blank");
        }));
    });
    if ($(".mw-special-ListDuplicatedFiles")[0] && $('.mw-spcontent > p')[1]) {
        if (window.location.href.indexOf("title") == -1) window.location.replace("http://commons.moegirl.org/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0");
        $('#mw-content-text .mw-spcontent ol').attr("id", "picOl");
        $('#picOl').before('<p id="picOlTitle">图片列表:</p>').after('<p id="MP3OlTitle">MP3列表:</p><ol start="1" id="MP3Ol"></ol>');
        $("#picOlTitle, #MP3OlTitle").hide();
        $("#picOl").find("[href$='.mp3'], [href$='.ogg']").parent().appendTo("#MP3Ol");
        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();
        if (mw.config.get('wgUserGroups').indexOf('sysop') !== -1) {
            if (mw.config.get('mgDuplicateFilesClean')) mw.config.get('mgDuplicateFilesClean')();
            else mw.config.set('mgDuplicateFilesClean', true);
        }
    }
    $(window).on('load', function() {
        $('#mw-content-text a').each(function() {
            try {
                var link = new mw.Uri(this.href);
                if (link.host !== 'commons.moegirl.org') return;
                if (/^\/api\.php/i.test(link.path)) return;
                if (!link.query.title && /\.php$/i.test(link.path)) return;
                if (link.query && (link.query.action || link.query.diff)) return;
                var href = link.query.title || decodeURI(link.path.substring(1));
                if (/^user:|^user[ _]talk:/i.test(href)) $(this).after('<sub>[<a target="_blank" title="主站上的“' + href + '”" href="https://zh.moegirl.org/' + href.match(/^user:[^\/]+|^user[ _]talk:[^\/]+/i)[0] + '">主</a>]</sub>');
            } catch (e) {
                return;
            }
        });
    });
    //修复代码编辑器$.ucFirst引用错误
    jQuery.extend({
        ucFirst: function(s) {
            s += '';
            return s.charAt(0).toUpperCase() + s.substring(1);
        }
    });
});