• 正在查找将来过去时的官方设定集?不如看看万界大百科吧!
  • 《将来过去时》第一部分 现在 魔科纪元的少年少女 即将正式发布!
  • 让我偷偷看一眼小鱼君的博客……
  • 服务器已成功迁移到 阿里云(杭州)

“User:机智的小鱼君/common.js”的版本间的差异

来自小鱼君和他的朋友们
([InPageEdit] 没有编辑摘要)
([InPageEdit] 没有编辑摘要)
 
第54行: 第54行:
 
   );
 
   );
 
});
 
});
 +
 +
/** 移动端调试 **/
 +
!(function () {
 +
  var loadScript = function (url) {
 +
   if (!/^(https?:)?\/\//.test(url)) url = mw.util.getUrl(url, { action: 'raw', ctype: 'text/javascript' })
 +
   return $.ajax({
 +
    url: url,
 +
    dataType: 'script',
 +
    cache: true
 +
   })
 +
  }
 +
  mw.loader.using('mediawiki.util').then(function () {
 +
   var url = mw.util.getParamValue('console')
 +
   if (url === '0' || url === 'false' || url === 'disable') {
 +
    localStorage.setItem('loadConsole', 'false')
 +
   } else if (url) {
 +
    localStorage.setItem('loadConsole', 'true')
 +
   }
 +
   if (localStorage.getItem('loadConsole') === 'true') {
 +
    loadScript('https://cdn.jsdelivr.net/npm/eruda').then(function () {
 +
     loadScript('https://cdn.jsdelivr.net/npm/eruda-dom')
 +
     loadScript('https://cdn.jsdelivr.net/npm/eruda-code')
 +
     eruda.init({
 +
      defaults: {
 +
       displaySize: 50
 +
      }
 +
     })
 +
    })
 +
   }
 +
  })
 +
})()

2021年1月13日 (三) 18:18的最新版本

// mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected]/dist/InPageEdit.min.js');

/** Get Fandom Code **/
$(function () {
  var pageName = mw.config.get('wgPageName');
  $('#p-cactions ul').append(
    $('<li>').append(
      $('<a>').attr('href', 'javascript:void(0)').text('查看Fandom代码').click(function () {
        ssi_modal.show({
          content: $('<div>').append(
            $('<textarea>', { style: 'width:100%; min-height:350px; height: 70vh;', readonly: true, val: 'Loading...' })
          ),
          center: true,
          title: 'Fandom上的' + pageName,
          buttons: [{
            label: '关闭',
            className: 'btn btn-danger',
            method: function (a, modal) { modal.close() }
          }, {
            label: '编辑本页面',
            className: 'btn',
            method: function () { InPageEdit.quickEdit() }
          }, {
            label: '在Fandom查看这个页面',
            className: 'btn btn-primary',
            method: function () { window.open('https://epbureau.fandom.com/wiki/' + pageName) }
          }],
          onShow: function (modal) {
            var $modal = $('#' + modal.modalId);
            $.ajax({
              url: 'https://epbureau.fandom.com/api.php',
              dataType: 'jsonp',
              type: 'post',
              data: {
                page: pageName,
                action: 'parse',
                prop: 'wikitext',
                format: 'json'
              },
              success: function (result) {
                var wikitext;
                if (result.parse !== undefined) {
                  wikitext = result.parse.wikitext['*'];
                } else {
                  wikitext = '<!-- 错误:无法读取Fandom上的同名页面。 -->'
                }
                $modal.find('textarea').val(wikitext);
              }
            });
          }
        });
      })
    )
  );
});

/** 移动端调试 **/
!(function () {
  var loadScript = function (url) {
    if (!/^(https?:)?\/\//.test(url)) url = mw.util.getUrl(url, { action: 'raw', ctype: 'text/javascript' })
    return $.ajax({
      url: url,
      dataType: 'script',
      cache: true
    })
  }
  mw.loader.using('mediawiki.util').then(function () {
    var url = mw.util.getParamValue('console')
    if (url === '0' || url === 'false' || url === 'disable') {
      localStorage.setItem('loadConsole', 'false')
    } else if (url) {
      localStorage.setItem('loadConsole', 'true')
    }
    if (localStorage.getItem('loadConsole') === 'true') {
      loadScript('https://cdn.jsdelivr.net/npm/eruda').then(function () {
        loadScript('https://cdn.jsdelivr.net/npm/eruda-dom')
        loadScript('https://cdn.jsdelivr.net/npm/eruda-code')
        eruda.init({
          defaults: {
            displaySize: 50
          }
        })
      })
    }
  })
})()