打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
9Yan留言 | 贡献
无编辑摘要
标签已被回退
9Yan留言 | 贡献
无编辑摘要
 
(未显示同一用户的26个中间版本)
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
$(function() {
    // 处理用户页面自动加载模板
    autoLoadUserPageTemplate();
});


/* SimpleMathJax支持预览设置 */
function waitForMathJax($content) {
  if (typeof MathJax === 'undefined') {
    setTimeout(function () { waitForMathJax($content); }, 1000);
  } else {
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
  }
}


mw.hook('wikipage.content').add(waitForMathJax);
function autoLoadUserPageTemplate() {
    // 获取当前命名空间、页面名称和文章ID
    const namespaceNumber = mw.config.get('wgNamespaceNumber');
    const pageName = mw.config.get('wgPageName');
    const userName = mw.config.get('wgUserName');
    const articleId = mw.config.get('wgArticleId');
    const userNameWithUnderscores = userName.replace(/ /g, '_');


{
    // 仅在用户页面且页面不存在时执行
const scrollTextLists = document.querySelectorAll('.scroll-text-list>ul');
    if (namespaceNumber !== 2 || pageName !== '用户:' + userNameWithUnderscores || articleId) {
setInterval(function() {
        return
for (var i = 0; i < scrollTextLists.length; ++i) {
    }
(function() {
    // 查找“创建页面”的链接或按钮
var list = scrollTextLists[i];
    let createPageLink = $('#ca-ve-edit a, #ca-edit a');
if (list.children.length < 2) {
    if (!createPageLink.length) {
return;
        return
}
    }
var repeat = 5;
 
var scrollBehavior = setInterval(function() {
    let href = createPageLink.attr('href');
if (repeat === 0) {
    if (href && href.indexOf('action=edit') !== -1) {
list.appendChild(list.firstElementChild);
        // 添加preload参数,自动加载用户页模板
list.style.marginTop = '0px';
        href += '&preload=Template:user_page';
clearInterval(scrollBehavior);
        createPageLink.attr('href', href);
return;
    }
}
--repeat
list.style.marginTop = (repeat - 5) * 5 + 'px';
}, 40)
})();
}
}, 10000);
}
}

2025年8月4日 (一) 16:48的最新版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
$(function() {
    // 处理用户页面自动加载模板
    autoLoadUserPageTemplate();
});


function autoLoadUserPageTemplate() {
    // 获取当前命名空间、页面名称和文章ID
    const namespaceNumber = mw.config.get('wgNamespaceNumber');
    const pageName = mw.config.get('wgPageName');
    const userName = mw.config.get('wgUserName');
    const articleId = mw.config.get('wgArticleId');
    const userNameWithUnderscores = userName.replace(/ /g, '_');

    // 仅在用户页面且页面不存在时执行
    if (namespaceNumber !== 2 || pageName !== '用户:' + userNameWithUnderscores || articleId) {
        return
    }
    // 查找“创建页面”的链接或按钮
    let createPageLink = $('#ca-ve-edit a, #ca-edit a');
    if (!createPageLink.length) {
        return
    }

    let href = createPageLink.attr('href');
    if (href && href.indexOf('action=edit') !== -1) {
        // 添加preload参数,自动加载用户页模板
        href += '&preload=Template:user_page';
        createPageLink.attr('href', href);
    }
}