|
|
第1行: |
第1行: |
| /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | | /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ |
| /* 参考的BWiki碧蓝航线*/
| | function getCookie(name) { |
| | | var value = '; ' + document.cookie; |
| /* 加载测试用js/css,稳定后加入Common.js/css */
| | var parts = value.split('; ' + name + '='); |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=MediaWiki:Test.js&action=raw&ctype=text/javascript", "text/javascript");
| | if (parts.length === 2) return parts.pop().split(';').shift(); |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=Mediawiki:Test.css&action=raw&ctype=text/css", "text/css");
| |
| | |
| /*= 解决jQuery冲突问题 =*/
| |
| | |
| /* --编辑摘要-- */
| |
| //参考Wikipedia:MediaWiki:Common.js/edit.js
| |
| if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit" || mw.config.get('wgCanonicalSpecialPageName') == 'Search') { // 编辑页面
| |
|
| |
| ( function( $, mw ) { $( function() {
| |
| if ( $( '#editform input[name=wpSection]' ).val() === 'new' ) {
| |
| if ( $( '#no-new-title' ).length ) {
| |
| $( '#wpSummary' ).attr( 'disabled', true );
| |
| }
| |
| return;
| |
| }
| |
| $( '#wpSummaryLabel .mw-summary-preset' ).on( 'click', '.mw-summary-preset-item a', function( e ) {
| |
| e.preventDefault();
| |
| var $this = $( this ), summary = $( '#wpSummary' ).val();
| |
| var $item = $this.parent( '.mw-summary-preset-item' );
| |
| summary = summary.replace( /\s+$/g, '' );
| |
| if ( summary != '' ) {
| |
| summary += ' ';
| |
| }
| |
| summary += $item.attr( 'title' ) || $this.text();
| |
| $this.replaceWith( $this.contents() );
| |
| $( '#wpSummary' ).val( summary ).focus();
| |
| } );
| |
| } ); } )( jQuery, mediaWiki );
| |
| | |
| } | | } |
|
| |
|
|
| |
|
| /* -- B站视频 --*/ | | // 特性支持:加载 Mediawiki:Main.js |
| var BiliVideo=document.getElementsByClassName("BiliVideo")
| | try { |
| for(var i=0,ilen=BiliVideo.length;i<ilen;i++){
| | if(localStorage.getItem('wukong-interface-admin')){/* 对前端管理员,加载无缓存的版本 */ |
| var v=BiliVideo[i].dataset.v
| | mw.loader.load("/wukong/MediaWiki:Main.js?action=raw&ctype=text/javascript&rand="+Math.random(), "text/javascript"); |
| if(!isNaN(v)){
| | } else { |
| v="aid="+v
| | mw.loader.load("/wukong/MediaWiki:Main.js?action=raw&ctype=text/javascript", "text/javascript"); |
| }
| |
| else if(/^av[0-9]+$/i.test(v)){
| |
| v="aid="+v.substr(2)
| |
| }
| |
| else if(/^bv[a-z0-9]+$/i.test(v)){
| |
| v="bvid=BV"+v.substr(2)
| |
| }
| |
| else{
| |
| v="bvid=BV"+v
| |
| }
| |
| var p="page="+(Number(BiliVideo[i].dataset.p)||1)
| |
| var w=Number(BiliVideo[i].dataset.w)||600
| |
| var h=Number(BiliVideo[i].dataset.h)||421
| |
| BiliVideo[i].innerHTML='<iframe src="//player.bilibili.com/player.html?'+v+'&'+p+'&autoplay=0" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" width="'+w+'" height="'+h+'" style="max-width:100%;max-height:60vw;"></iframe>'
| |
| } | | } |
| | }catch(e) { console.log("Error, MediaWiki:Main.js 加载失败");console.error(e, e.stack);} |
|
| |
|
|
| |
|
| /* --首页新闻滚动--
| | try { |
| if ($(".marquee_item").length > 0) {
| | mw.loader.load("/wukong/MediaWiki:BWikiLocalUser.js?action=raw&ctype=text/javascript", "text/javascript"); |
| var itemparent = $(".marquee_item").first().parent() | | }catch(e) { console.log("Error, MediaWiki:BWikiLocalUser.js 加载失败");console.error(e, e.stack);} |
| var itemlist = $(".marquee_item").remove()
| |
| itemparent.append("<marquee></marquee>").children("marquee").prepend(itemlist)
| |
| }*/ | |
|
| |
|
|
| |
|
| | // 特性支持:加载 编辑器扩展 MediaWiki:EditorExt.js |
| | try { |
| | mw.loader.load("/wukong/MediaWiki:EditorExt.js?action=raw&ctype=text/javascript&v=2412.1", "text/javascript"); |
| | }catch(e) { console.log("Error, MediaWiki:HoverToc.js 加载失败");console.error(e, e.stack);} |
|
| |
|
| var nsNum = mw.config.exists('wgNamespaceNumber')
| | /* 加载 font-awesome */ |
| ? mw.config.get('wgNamespaceNumber')
| | mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css', 'text/css'); |
| : -1;
| |
|
| |
|
| |
|
| //命名空间:主要、模板
| |
| if (nsNum == -1 || nsNum == 0 || nsNum == 10) {
| |
| /* --Tab标签页-- 已改为ResourceLoader加载*/
| |
| /* mw.loader.load("https://wiki.biligame.com/blhx/index.php?title=MediaWiki:Tab.js&action=raw&ctype=text/javascript"); */
| |
| }
| |
|
| |
|
| //命名空间:主要 | | // 特性支持: 快捷编辑理由。支持编辑摘要时,点击快捷选项填充编辑理由 |
| if (nsNum == -1 || nsNum == 0) { | | // 参考Wikipedia:MediaWiki:Common.js/edit.js 转换为无需JQuery的写法 |
|
| | function fast_edit_summary_btn() { |
| /* --声明-- */
| | if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit" || mw.config.get('wgCanonicalSpecialPageName') == 'Search') { // 编辑页面 |
| mw.loader.load("https://wiki.biligame.com/blhx/index.php?title=MediaWiki:CC_BY-NC-SA.js&action=raw&ctype=text/javascript");
| | var wpSectionInput = document.querySelector('#editform input[name="wpSection"]'); |
| | |
| | if (wpSectionInput && wpSectionInput.value === 'new') { |
| | if (document.getElementById('no-new-title')) { |
| | document.getElementById('wpSummary').setAttribute('disabled', true); |
| | } |
| | return; |
| | } |
|
| |
|
| | var presetContainer = document.querySelector('#wpSummaryLabel .mw-summary-preset'); |
| | if (presetContainer) { |
| | presetContainer.addEventListener('click', function(e) { |
| | if (e.target && e.target.matches('.mw-summary-preset-item a')) { |
| | e.preventDefault(); |
| | |
| | var summaryInput = document.getElementById('wpSummary'); |
| | var summary = summaryInput.value; |
| | var item = e.target.closest('.mw-summary-preset-item'); |
| | |
| | summary = summary.replace(/\s+$/g, ''); |
| | if (summary !== '') { |
| | summary += ' '; |
| | } |
| | |
| | summary += item.getAttribute('title') || e.target.textContent; |
| | |
| | summaryInput.value = summary; |
| | summaryInput.focus(); |
| | } |
| | }); |
| | } |
| | }/* end if 'wgAction'*/ |
| | }/* end function */ |
| | if (document.readyState === "loading") { |
| | document.addEventListener("DOMContentLoaded", fast_edit_summary_btn); |
| | } else { |
| | fast_edit_summary_btn(); |
| } | | } |
| | /* end 特性支持: 快捷编辑理由 */ |
|
| |
|
| /* -- 验证上传文件 --*/
| |
| $(function() {
| |
| if (mw.config.get('wgPageName') === '特殊:上传文件') {
| |
| mw.loader.load("https://wiki.biligame.com/blhx/index.php?title=MediaWiki:UploadValidation.js&action=raw&ctype=text/javascript");
| |
| }
| |
| });
| |
|
| |
|
| | // 特性支持: 加载main.css |
| | try { |
| | if(window._is_main_css_loaded){ |
| | /* do nothing 因为在全站通知已经尝试加载一次了,正常情况下不需要再次加载 */ |
| | }else{ |
| | var head = document.getElementsByTagName('head')[0]; |
| | var main_css_link = document.createElement('link'); |
| | main_css_link.rel = 'stylesheet'; |
| | main_css_link.type = 'text/css'; |
| | main_css_link.href = 'https://wiki.biligame.com/wukong/MediaWiki:Main.css?action=raw&ctype=text/css'; |
| | if(localStorage.getItem('wukong-interface-admin')){ |
| | console.log("Widget:LoadMainCSS: 尝试加载无缓存版本的 MediaWiki:Main.css "); |
| | main_css_link.href = 'https://wiki.biligame.com/wukong/MediaWiki:Main.css?action=raw&ctype=text/css&rand=' + Math.random(); |
| | } |
| | head.appendChild(main_css_link); |
|
| |
|
| window.onload=function(){ | | window._is_main_css_loaded = true; |
| /* --页面加载完毕后加载-- */
| |
| | |
| /* --Clear Body-- */
| |
| if(document.getElementById("clearbody")){
| |
| document.body.innerHTML=document.getElementById("clearbody").innerHTML
| |
| } | | } |
| /* --{{模板:网易云音乐}}-- */
| | }catch(e) { console.log("MediaWiki:Common.js:Error, MediaWiki:Main.css 加载失败");console.error(e, e.stack);} |
| createMusic163OutChain()
| | /* end 特性支持:加载main.css */ |
|
| |
|
| /* --页面加载完毕后加载(完)-- */
| |
| }
| |
|
| |
|
| //添加【信息】按钮来查看页面的属性信息 | | /* 特性支持:参见[[模板:ResourceLoader]]*/ |
| $(function(){ | | $('.resourceLoader').each(function() { |
| var $ca = $('#p-cactions > ul.menu > li#ca-history'); | | var $x = $(this); |
| var href = $ca.children('a').attr('href'); | | var text = $.trim($x.text()); |
| | | |
| if ($ca[0] && href) { | | if (!text) return; |
| $ca.after('<li id="ca-info"><a href="'
| | |
| + href.replace('action=history','action=info')
| | //加载模块 |
| +'" title="本页面的信息">信息</a></li>'
| | if ($x.data('isModule') == true) |
| )
| | return mw.loader.load(text); |
| | |
| | //自动补充MediaWiki命名空间,也就是说,只允许加载MediaWiki命名空间的资源。 |
| | var ns = text.match('^.*?:'); |
| | if (!ns) text = 'MediaWiki:' + text; |
| | |
| | //加载CSS样式表 |
| | var mime = ($x.data('mime') || "text/javascript").toLowerCase(); |
| | if (mime == "text/css") { |
| | if (text.slice(-4).toLowerCase() !== '.css') text = text + '.css'; |
| | if ($x.data('debug') !== true) text = text + '&debug=true&r='+Math.random(); |
| | return mw.loader.load("//wiki.biligame.com/wukong/index.php?title="+text+"&action=raw&ctype=text/css", "text/css"); |
| } | | } |
| | |
| | //加载JS脚本 |
| | if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js'; |
| | if ($x.data('debug') !== true) text = text + '&debug=true&r='+Math.random(); |
| | return mw.loader.load("//wiki.biligame.com/wukong/index.php?title="+text+"&action=raw&ctype=text/javascript", "text/javascript"); |
| }); | | }); |
| | /* end 特性支持: ResourceLoader */ |
|
| |
|
| /* -- 为页面加载JS脚本或CSS样式表 -- */
| |
| /* 参见[[模板:ResourceLoader]]*/
| |
| /* 将相关代码用改为DOM加载完成后运行,解决部分情况
| |
| 模板:ResourceLoader加载不完全的问题 -- 芙兰朵露琪露诺 2021/8/11*/
| |
|
| |
|
| function templateResourceLoader() {
| | /* 特性支持:加载字体, 利用indexedDB缓存 */ |
| $('.resourceLoader').each(function() {
| | /* |
| var $x = $(this);
| | try { |
| var text = $.trim($x.text());
| | function loadFonts() { |
|
| | var dbName = "WuKong"; |
| if (!text) return;
| | var objectStoreName = "fonts"; |
|
| | var dbVersion = 1; |
| //加载模块
| | var db = null; |
| if ($x.data('isModule') == true)
| |
| return mw.loader.load(text);
| |
|
| |
| //自动补充MediaWiki命名空间
| |
| var ns = text.match('^.*?:');
| |
| if (!ns) text = 'MediaWiki:' + text;
| |
|
| |
| //加载CSS样式表
| |
| var mime = ($x.data('mime') || "text/javascript").toLowerCase();
| |
| if (mime == "text/css") {
| |
| if (text.slice(-4).toLowerCase() !== '.css') text = text + '.css';
| |
| //if ($x.data('debug') !== true) text = text + '&debug=false';
| |
| return mw.loader.load("//wiki.biligame.com/blhx/index.php?title="+text+"&action=raw&ctype=text/css", "text/css");
| |
| }
| |
|
| |
| //加载JS脚本
| |
| if (ns && ns[0].toLowerCase() !== 'mediawiki:') {
| |
| return console.log('ResourceLoader: 不允许加载MediaWiki以外的js脚本');
| |
| }
| |
| if (text.slice(-3).toLowerCase() !== '.js') text = text + '.js';
| |
| console.log('ResourceLoader: 加载' + text);
| |
| //if ($x.data('debug') !== true) text = text + '&debug=false';
| |
| return mw.loader.load("//wiki.biligame.com/blhx/index.php?title="+text+"&action=raw&ctype=text/javascript", "text/javascript");
| |
| });
| |
| }
| |
|
| |
|
| function loadAfterDOM(func) { | | function getFontData(key, fontName, weight) { |
| if (document.readyState == 'loading') {
| | var objectStore = db.transaction([objectStoreName], "readonly").objectStore(objectStoreName); |
| document.addEventListener('DOMContentLoaded', func);
| | var getRequest = objectStore.get(key); |
| } else {
| |
| func();
| |
| }
| |
| }
| |
|
| |
|
| loadAfterDOM(templateResourceLoader);
| | getRequest.onsuccess = function (event) { |
| | fontData = event.target.result; |
| | if (fontData) { |
| | console.log('尝试加载' + fontName + '本地缓存'); |
| | var fontFace = new FontFace(fontName, 'url(' + fontData + ')', { weight: weight }); |
| | fontFace.load().then(function () { |
| | document.fonts.add(fontFace); |
| | }); |
| | } else { |
| | var url = '/wukong/index.php?title=MediaWiki:' + key + '.js&action=raw&ctype=text/javascript'; |
| | var urlWithRand = url + '&rand=' + Math.random(); |
| | var loadUrl = localStorage.getItem('wukong-interface-admin') ? urlWithRand : url; |
| | mw.loader.load(loadUrl, "text/javascript"); |
| | } |
| | }; |
| | } |
|
| |
|
| /* 加载常用ResourceLoader JS模块 */
| | var request = indexedDB.open(dbName, dbVersion); |
| | request.onupgradeneeded = function (event) { |
| | var db = event.target.result; |
| | if (!db.objectStoreNames.contains(objectStoreName)) { |
| | db.createObjectStore(objectStoreName, { keyPath: "key", autoIncrement: false }); |
| | } |
| | }; |
| | request.onsuccess = function (event) { |
| | db = event.target.result; |
| | getFontData("Font-Yang-Regular", "杨任东竹石体", "normal"); |
| | getFontData("Font-Yang-Bold", "杨任东竹石体", "bold"); |
| | }; |
| | } |
|
| |
|
| function loadCommonJS() {
| | loadFonts(); |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=MediaWiki:HashTab.js&action=raw&ctype=text/javascript", "text/javascript");
| | } catch (error) { |
| console.log('ResourceLoader: 加载MediaWiki:HashTab.js');
| | console.error("Error:", error); |
| } | | } |
| | */ |
|
| |
|
| loadAfterDOM(loadCommonJS);
| | //编辑器插件SmartClick引入 |
| | $(function(){ |
| | mw.loader.load("//wiki.biligame.com" + mw.util.wikiScript("") + "?title=MediaWiki:SmartClick.js&action=raw&ctype=text/javascript", "text/javascript"); |
| | console.log("SmartClick.js initialized!"); |
| | }); |
|
| |
|
| /* 活动船自助标记 */
| |
| eventShipMarkTable=document.getElementsByClassName("eventShipMark")
| |
| eventShipMark=new Array()
| |
| for(i=0;i<eventShipMarkTable.length;i++){
| |
| eventShipMark[i]=eventShipMarkTable[i].getElementsByTagName("tr")
| |
| for(j=0;j<eventShipMark[i].length;j++){
| |
| eventShipMark[i][j].onclick=function(){
| |
| if(this.style.opacity=="0.2"){
| |
| this.style.opacity="1"
| |
| }
| |
| else{
| |
| this.style.opacity="0.2"
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| /* --直播提醒--
| |
| Airtime="2020/9/12 19:00:00" //直播时间
| |
| Airinfo="「碧蓝航线日服三周年」直播" //直播名称
| |
| Airlink="https://live.bilibili.com/775277" //直播地址
| |
|
| |
|
| Airremind=self.setInterval(function(){
| | // https://wiki.biligame.com/umamusume/MediaWiki:Common.js |
| if(new Date(Airtime).getTime()-new Date().getTime()-(8+new Date().getTimezoneOffset()/60)*60*60*1000<=3*60*1000&&new Date(Airtime).getTime()-new Date().getTime()-(8+new Date().getTimezoneOffset()/60)*60*60*1000>=-3*60*1000){ //开播前3分钟到开播后3分钟之间 | | // 加载ES6模块 |
| if(getCookie("Airreminded")!=1){ //检查是否提醒过
| | function loadModuleES6(src, callback) { |
| Airremindexpires=new Date() | | var script = document.createElement('script'), |
| Airremindexpires.setTime(Airremindexpires.getTime()+60*60*1000) | | head = document.getElementsByTagName('head')[0]; |
| document.cookie="Airreminded=1;expires="+Airremindexpires.toGMTString() //只会提醒一次
| | script.type = 'module'; |
| if(new Date(Airtime).getTime()-new Date().getTime()-(8+new Date().getTimezoneOffset()/60)*60*60*1000<=3*60*1000&&new Date(Airtime).getTime()-new Date().getTime()-(8+new Date().getTimezoneOffset()/60)*60*60*1000>=0){
| | script.charset = 'UTF-8'; |
| isAiring="即将开播" | | script.src = src; |
| | if (script.addEventListener) { |
| | script.addEventListener('load', function () { |
| | callback(); |
| | }, false); |
| | } else if (script.attachEvent) { |
| | script.attachEvent('onreadystatechange', function () { |
| | var target = window.event.srcElement; |
| | if (target.readyState == 'loaded') { |
| | callback(); |
| } | | } |
| else {
| | }); |
| isAiring="正在直播"
| |
| }
| |
| Airjump=confirm(Airinfo+"\n"+isAiring+"\n是否跳转?") //信息
| |
| if(Airjump){
| |
| openWindow(Airlink) //点确定跳转
| |
| }
| |
| } | |
| window.clearInterval(Airremind) //停止检查
| |
| } | | } |
| else if(new Date(Airtime).getTime()-new Date().getTime()-(8+new Date().getTimezoneOffset()/60)*60*60*1000<-3*60*1000){ //开播后3分钟 | | head.appendChild(script); |
| window.clearInterval(Airremind) //停止检查
| |
| }
| |
| },1000)
| |
| function getCookie(c_name){
| |
| if(document.cookie.length>0){
| |
| c_start=document.cookie.indexOf(c_name+"=")
| |
| if(c_start!=-1){
| |
| c_start=c_start+c_name.length+1
| |
| c_end=document.cookie.indexOf(";",c_start)
| |
| if(c_end==-1){
| |
| c_end=document.cookie.length
| |
| }
| |
| return unescape(document.cookie.substring(c_start,c_end))
| |
| }
| |
| }
| |
| return ""
| |
| } | | } |
| function openWindow(url){
| |
| var link=document.createElement("a")
| |
| link.target="_blank"
| |
| link.href=url
| |
| document.body.appendChild(link)
| |
| link.click()
| |
| document.body.removeChild(link)
| |
| }*/
| |
|
| |
|
| /*-- 载入有道网页翻译功能 | | //加载表情包插件 |
| NeedT=document.getElementById("translationBTN")
| | // 来自seerplan,源自umamusume |
| if(NeedT){
| | $(function(){ |
| NeedT.href="javascript:void((function(){var a=document.createElement('script');a.id='outfox_seed_js';a.charset='utf-8',a.setAttribute('src','http://fanyi.youdao.com/web2/seed.js?'+Date.parse(new Date()));document.body.appendChild(a)})())"
| | loadModuleES6("//wiki.biligame.com/wukong/index.php?title=MediaWiki:Emotion.js&action=raw&ctype=text/javascript", function() { |
| }
| | console.log("Flowthread Add-on Emotion loaded!"); |
| --*/
| | }); |
| | |
| /*-- 将类名为shikikanname的元素的内容改变为当前用户名 --*/
| |
| $(document).ready(function() {
| |
| shikikannamespan=document.getElementsByClassName("shikikanname")
| |
| if (UserStatus.userInfo) {
| |
| shikikanname=UserStatus.userInfo.uname
| |
| for(i=0;i<shikikannamespan.length;i++){
| |
| shikikannamespan[i].innerHTML=shikikanname
| |
| }
| |
| } else {
| |
| function waitForName(){
| |
| if(typeof UserStatus.userInfo !== "undefined"){
| |
| shikikanname=UserStatus.userInfo.uname
| |
| for(i=0;i<shikikannamespan.length;i++){
| |
| shikikannamespan[i].innerHTML=shikikanname
| |
| }
| |
| }
| |
| else{
| |
| setTimeout(waitForName, 1000);
| |
| }
| |
| }
| |
| waitForName()
| |
| }
| |
| // if(!shikikanname){
| |
| // shikikanname="指挥官"
| |
| // }
| |
| // for(i=0;i<shikikannamespan.length;i++){
| |
| // shikikannamespan[i].innerHTML=shikikanname
| |
| // }
| |
| });
| |
| | |
| /*-- 重新加载flowthread插件修复js加载过早导致的评论区缺失 --*/
| |
| $(document).ready(function() {
| |
| if (nsNum == 0) {
| |
| mw.loader.using('ext.flowthread').then(function () {
| |
| setTimeout(function() {
| |
| if (!$(".post-content").length) {
| |
| if (!$(".post-content").length) {
| |
| mw.loader.load('https://wiki.biligame.com/blhx/load.php?lang=zh-cn&modules=ext.flowthread&only=scripts&raw=1&skin=vector', 'text/javascript')
| |
| setTimeout(function() {
| |
| if ($('.post-content').length > 1) {
| |
| $('.post-content')[0].remove();
| |
| }
| |
| }, 2000);
| |
| }
| |
| }
| |
| } ,2000);
| |
| });
| |
| }
| |
| });
| |
| | |
| /*-- 为手机端非登录用户在导航添加登录按钮 --*/
| |
| $(document).ready(function() {
| |
| if(mw.config.get('wgUserName')===null){
| |
| loginli=document.createElement("li");
| |
| loginli.classList.add("li-menu-1");
| |
| loginli.innerHTML="<a class='menu-title' style='border-radius:5px;background-color:#00B5E5;color:white;text-align:center' href='https://passport.bilibili.com/login'>登录</a>"
| |
| document.getElementsByClassName("m-nav")[0].getElementsByClassName("ul-menu-1")[0].insertBefore(loginli,document.getElementsByClassName("m-nav")[0].getElementsByClassName("ul-menu-1")[0].getElementsByClassName("li-menu-1")[0]);
| |
| }
| |
| });
| |
| | |
| /* --修正equip.js引起的选项卡面板无法嵌套-- */
| |
| $(document).ready(function() {
| |
| setTimeout(function() {
| |
| $(document).off("click", ".nav-tabs > li");
| |
| //$.conflict()(document).off("click", ".nav-tabs > li");
| |
| } ,500);
| |
| });
| |
| | |
| /* --临时修正jsDelivr被墙导致的国内用户TeX公式无法渲染问题-- */
| |
| $(document).ready(function() { | |
| setTimeout(function() { | |
| if(window.MathJax && window.MathJax.tex!==undefined) {
| |
| window.MathJax.loader={load:[]};
| |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=MediaWiki:Tex-chtml.js&action=raw&ctype=text/javascript", "text/javascript");
| |
| }
| |
| } ,500);
| |
| });
| |
| | |
| biliUserName = {}
| |
| /*将UID数字替换为B站个人动态页面 源自CQ WIKI*/
| |
| $(document).ready(function() {
| |
| if($(".mw-userlink").length>0){
| |
| $(".mw-userlink bdi").each(function(){
| |
| var uid = $(this).html().replace(/\(/i,"").replace(/\)/i,"");
| |
| $(this).parent("a").attr("href","https://space.bilibili.com/"+uid+"/").attr("title","TA的B站空间").attr("target","_blank");
| |
| //console.log(uid);
| |
| if(biliUserName[uid] === undefined) {
| |
| biliUserName[uid] = [];
| |
| }
| |
| biliUserName[uid].push(this)
| |
| $(this).html("");
| |
| });
| |
|
| |
| //临时修复编辑历史缺失用户名问题
| |
| var api = new mw.Api();
| |
| function fillName (name, field) {
| |
| for (var i = 0; i < field.length; i++) {
| |
| field[i].innerText = name;
| |
| }
| |
| }
| |
| var query = "";
| |
| for (var i in biliUserName) {
| |
| query += '{{#tag:bilicontributors|'+ i +'}}}';
| |
| }
| |
| api.get({
| |
| action: "parse",
| |
| text: query
| |
| }).then(function(ret) {
| |
| var wrapper= document.createElement('div');
| |
| wrapper.innerHTML= ret.parse.text['*'];
| |
| var list = wrapper.getElementsByClassName('user-follow-wrap');
| |
| list.forEach(function(item) {
| |
| var uid = parseInt(item.querySelector('.detail-follow').attributes.fid.value);
| |
| var name = item.querySelector('.des-name').innerText;
| |
| fillName(name, biliUserName[uid]);
| |
| });
| |
| });
| |
| }
| |
| });
| |
| | |
| /*检测js是否正常加载*/
| |
| $(document).ready(function() {
| |
| setTimeout(function() {
| |
| document.getElementById("wiki-resourceloader-check").style.display="none";
| |
| var purgeThisPage = document.getElementById("PurgeThisPageSiteNotice")
| |
| if (purgeThisPage) {
| |
| var link = purgeThisPage.children[0]
| |
| link.href = link.href.replace("FullPageName", mw.config.values.wgPageName)
| |
| }
| |
| } ,2000); | |
| }); | | }); |