|
|
(未显示同一用户的17个中间版本) |
第1行: |
第1行: |
| /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | | // 引入jQuery计时器插件[6](@ref) |
| /* 参考的BWiki碧蓝航线*/ | | mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js'); |
|
| |
|
| /* 加载测试用js/css,稳定后加入Common.js/css */ | | // 维护开始时间戳(2025-04-05 03:00:00 UTC) |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=MediaWiki:Test.js&action=raw&ctype=text/javascript", "text/javascript");
| | // 维护开始时间(示例:2020-09-01 00:00:00 UTC) |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=Mediawiki:Test.css&action=raw&ctype=text/css", "text/css");
| | const startTimestamp = 1743793200; |
|
| |
|
| /*= 解决jQuery冲突问题 =*/
| | function updateMaintenanceTimer() { |
| /*= 冲突问题版本更新已修复 =*/
| | const now = Math.floor(Date.now() / 1000); // 当前时间戳(秒) |
| /*(function() {
| | const duration = now - startTimestamp; |
| var $0 = $;
| |
| var $1 = window.$;
| |
| if ($0 == $1) {
| |
| $0.noConflict();
| |
| $1 = window.$ || $0;
| |
| window.$ = $0;
| |
| }
| |
| $0.conflict = function() { return $1 };
| |
| $1.conflict = function() { return $0 };
| |
| })();*/
| |
|
| |
|
| /*修复音频播放文字*/ | | // 计算天、小时、分钟 |
| $('.audio_player-playpause a').text('');
| | const days = Math.floor(duration / 86400); |
| | const hours = Math.floor((duration % 86400) / 3600); |
| | const minutes = Math.floor((duration % 3600) / 60); |
| | const seconds = duration % 60; |
|
| |
|
| /* 新播放器 {{模板:音频}} */ | | // 更新页面显示 |
| $('.audio-controls').click(function () {
| | const timerElement = document.getElementById("maintenance-timer"); |
| var audio = $(this).parent().find('audio').get(0);
| | if (timerElement) { |
| audio.addEventListener('ended', audioEnded, false); // 监听播放完成事件
| | timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`; |
| // 改变暂停/播放icon
| |
| if (audio.paused) {
| |
| audio.play();
| |
| $(this).find('.icon-btn').removeClass('icon-play').addClass('icon-pause');
| |
| } else {
| |
| audio.pause();
| |
| $(this).find('.icon-btn').removeClass('icon-pause').addClass('icon-play');
| |
| }
| |
| }) | |
| // 播放完成
| |
| function audioEnded() {
| |
| var audio = this;
| |
| var button=$(audio).siblings('.audio-controls').find('.icon-btn')
| |
| audio.currentTime = 0;
| |
| audio.pause();
| |
| button.removeClass('icon-pause').addClass('icon-play');
| |
| }
| |
| | |
| // {{模板:网易云音乐}}
| |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=Mediawiki:Music163OutChain.js&action=raw&ctype=text/javascript", "text/javascript");
| |
| // {{模板:舰队模拟器/舰队}}
| |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=Mediawiki:AzurLaneFleetShare.css&action=raw&ctype=text/css", "text/css");
| |
| | |
| /* --编辑摘要-- */
| |
| //参考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站视频 --*/
| | updateMaintenanceTimer(); |
| var BiliVideo=document.getElementsByClassName("BiliVideo")
| | // 每秒刷新 |
| for(var i=0,ilen=BiliVideo.length;i<ilen;i++){
| | setInterval(updateMaintenanceTimer, 1000); |
| var v=BiliVideo[i].dataset.v
| |
| if(!isNaN(v)){
| |
| v="aid="+v
| |
| }
| |
| 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>'
| |
| }
| |
| | |
| | |
| /* --首页新闻滚动--
| |
| if ($(".marquee_item").length > 0) {
| |
| var itemparent = $(".marquee_item").first().parent()
| |
| var itemlist = $(".marquee_item").remove()
| |
| itemparent.append("<marquee></marquee>").children("marquee").prepend(itemlist)
| |
| }*/
| |
| | |
| | |
| | |
| var nsNum = mw.config.exists('wgNamespaceNumber')
| |
| ? mw.config.get('wgNamespaceNumber')
| |
| : -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) {
| |
|
| |
| /* --声明-- */
| |
| mw.loader.load("https://wiki.biligame.com/blhx/index.php?title=MediaWiki:CC_BY-NC-SA.js&action=raw&ctype=text/javascript");
| |
| | |
| }
| |
| | |
| /* -- 验证上传文件 --*/
| |
| $(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");
| |
| }
| |
| });
| |
| | |
| | |
| window.onload=function(){
| |
| /* --页面加载完毕后加载-- */
| |
| | |
| /* --Clear Body-- */
| |
| if(document.getElementById("clearbody")){
| |
| document.body.innerHTML=document.getElementById("clearbody").innerHTML
| |
| }
| |
| /* --{{模板:网易云音乐}}-- */
| |
| createMusic163OutChain()
| |
| | |
| /* --页面加载完毕后加载(完)-- */
| |
| }
| |
| | |
| //添加【信息】按钮来查看页面的属性信息
| |
| $(function(){
| |
| var $ca = $('#p-cactions > ul.menu > li#ca-history');
| |
| var href = $ca.children('a').attr('href');
| |
| | |
| if ($ca[0] && href) {
| |
| $ca.after('<li id="ca-info"><a href="'
| |
| + href.replace('action=history','action=info')
| |
| +'" title="本页面的信息">信息</a></li>'
| |
| )
| |
| }
| |
| });
| |
| | |
| /* -- 为页面加载JS脚本或CSS样式表 -- */
| |
| /* 参见[[模板:ResourceLoader]]*/
| |
| /* 将相关代码用改为DOM加载完成后运行,解决部分情况
| |
| 模板:ResourceLoader加载不完全的问题 -- 芙兰朵露琪露诺 2021/8/11*/
| |
| | |
| function templateResourceLoader() {
| |
| $('.resourceLoader').each(function() {
| |
| var $x = $(this);
| |
| var text = $.trim($x.text());
| |
|
| |
| if (!text) return;
| |
|
| |
| //加载模块
| |
| 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) {
| |
| if (document.readyState == 'loading') {
| |
| document.addEventListener('DOMContentLoaded', func);
| |
| } else {
| |
| func();
| |
| }
| |
| }
| |
| | |
| loadAfterDOM(templateResourceLoader);
| |
| | |
| /* 加载常用ResourceLoader JS模块 */ | |
| | |
| function loadCommonJS() {
| |
| mw.loader.load("//wiki.biligame.com/blhx/index.php?title=MediaWiki:HashTab.js&action=raw&ctype=text/javascript", "text/javascript");
| |
| console.log('ResourceLoader: 加载MediaWiki:HashTab.js');
| |
| }
| |
| | |
| loadAfterDOM(loadCommonJS);
| |
| | |
| /* 活动船自助标记 */
| |
| 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(){
| |
| 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分钟之间
| |
| if(getCookie("Airreminded")!=1){ //检查是否提醒过
| |
| Airremindexpires=new Date()
| |
| Airremindexpires.setTime(Airremindexpires.getTime()+60*60*1000)
| |
| document.cookie="Airreminded=1;expires="+Airremindexpires.toGMTString() //只会提醒一次
| |
| 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){
| |
| isAiring="即将开播"
| |
| }
| |
| 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分钟
| |
| 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")
| |
| if(NeedT){
| |
| 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)})())"
| |
| }
| |
| --*/
| |
| | |
| /*-- 将类名为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);
| |
| });
| |