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

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
Kuina留言 | 贡献
无编辑摘要
Kuina留言 | 贡献
无编辑摘要
标签已被回退
第5行: 第5行:
}
}


mw.loader.using('mediawiki.Uri', function () {
$(document).ready(function() {
  $(document).ready(function () {
  // 查找所有以 /index.php? 开头的链接
    $('a').each(function () {
  $('a[href^="/index.php?"]').each(function() {
      var href = $(this).attr('href');
    var href = $(this).attr('href');
      if (href && href.indexOf('veaction=edit') !== -1) {
    // 判断链接中是否含有 action=veedit 参数
        // 解析链接
    if (href.indexOf('action=veedit') !== -1) {
        var uri = new mw.Uri(href);
      // 通过正则匹配提取 title 参数的值
        if (uri.query.veaction === 'edit') {
      var titleMatch = href.match(/(?:\?|&)title=([^&]+)/);
          // 将参数替换为 action=veedit
      if (titleMatch && titleMatch[1]) {
          delete uri.query.veaction;
        var title = decodeURIComponent(titleMatch[1]);
          uri.query.action = 'veedit';
        // 构造新的短链接形式:/w/veedit/Page_title
          // 构造新的 URL(去除 index.php 部分,让它符合短链接结构)
        var newHref = '/w/veedit/' + encodeURIComponent(title);
          // 假设正常页面链接结构为 /wiki/Page_title,因此这里用 veedit 替换 edit 的部分
        $(this).attr('href', newHref);
          var newHref = '/w/veedit/' + encodeURIComponent(uri.query.title || uri.path);
          // 保留其他查询参数
          var params = [];
          $.each(uri.query, function (key, val) {
            if (key !== 'title') {
              params.push(key + '=' + encodeURIComponent(val));
            }
          });
          if (params.length) {
            newHref += '?' + params.join('&');
          }
          // 更新链接
          $(this).attr('href', newHref);
        }
       }
       }
     });
     }
   });
   });
});
});

2025年5月16日 (五) 12:26的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
if (mw.config.get('wgPageName') === '首页'){
importScript( 'MediaWiki:Mainpage.js' );
} else {
}

$(document).ready(function() {
  // 查找所有以 /index.php? 开头的链接
  $('a[href^="/index.php?"]').each(function() {
    var href = $(this).attr('href');
    // 判断链接中是否含有 action=veedit 参数
    if (href.indexOf('action=veedit') !== -1) {
      // 通过正则匹配提取 title 参数的值
      var titleMatch = href.match(/(?:\?|&)title=([^&]+)/);
      if (titleMatch && titleMatch[1]) {
        var title = decodeURIComponent(titleMatch[1]);
        // 构造新的短链接形式:/w/veedit/Page_title
        var newHref = '/w/veedit/' + encodeURIComponent(title);
        $(this).attr('href', newHref);
      }
    }
  });
});
我们为您提供服务需要使用Cookie。使用我们的服务即表示您同意我们使用Cookie。