User:Irukaza/common.js:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
无编辑摘要
imported>=海豚=
(清空页面)
第1行: 第1行:
(function ($, mw) {


//加载内链脚本
function loadScript(scriptPath){
   var pageTitle = encodeURIComponent(scriptPath);
   mw.loader.load("https://www.hmoegirl.com/index.php?title=" + pageTitle + "&action=raw&ctype=text/javascript");
}
//是否为移动版
var isMobile = window.location.href.indexOf("m.hmoegirl.com") != -1;
function mobile(onMobile){
   if(isMobile){
     onMobile();
   }
}
function desktop(onDesktop){
   if(!isMobile){
     onDesktop();
   }
}
//添加Navbox
function addNavbox(){
   var pageName = mw.config.get("wgPageName");
   $.get("https://m.hmoegirl.com/api.php",{action:"parse",page:pageName,format:"json"},function(data,status){
     if(status == "success"){
       var desktopView = $($.parseJSON(data.replace("\"*\"","\"data\"")).parse.text.data);
       var navbox = desktopView.find(".navbox");
       navbox.each(function(){
         //查论编
         var viewTemplateLink = $(this).find("div.hlist.navbar").first();
         var templateView = $("<div class=\"plainlinks\" style=\"color:#aaa;transform:translate(-1.7px,20.9px);\">[</div>");
         templateView.append($(viewTemplateLink.html()));
         templateView.append("]");
         templateView.find("span").removeAttr("style");
         $("div.mw-parser-output").first().append(templateView);
         $("div.mw-parser-output").first().append($(this));
       });
       navbox.ready(function (){
       mw.loader.using("jquery.makeCollapsible").then(function (){
       $(".mw-collapsible").makeCollapsible();
       });
       });
     }
   },"text");
}
mobile(function(){
   if($("div.mw-parser-output")[0] !== undefined){
     var currentNavbox = $(document).find(".navbox");
     if(currentNavbox.length === 0){
       addNavbox();
     }
   }
});
})(jQuery, mediaWiki);

2021年8月1日 (日) 23:34的版本