|  |   | 
| 第1行: | 第1行: | 
|  | /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ |  | // 安全的时间解析(兼容所有浏览器) | 
|  | function getCookie(name) { |  | function parseDate(dateStr) { | 
|  |    var value = '; ' + document.cookie; |  |    // ISO格式:2025-04-05T03:00:08:00 | 
|  |   var parts = value.split('; ' + name + '=');
 |  |    if (dateStr.includes('T')) { | 
|  |   if (parts.length === 2) return parts.pop().split(';').shift();
 |  |      return new Date(dateStr); | 
|  | }
 |  | 
|  |   |  | 
|  |   |  | 
|  | // 特性支持:加载 Mediawiki:Main.js |  | 
|  | try {
 |  | 
|  | if(localStorage.getItem('wukong-interface-admin')){/* 对前端管理员,加载无缓存的版本 */
 |  | 
|  |     mw.loader.load("/wukong/MediaWiki:Main.js?action=raw&ctype=text/javascript&rand="+Math.random(), "text/javascript");
 |  | 
|  | } else {
 |  | 
|  |     mw.loader.load("/wukong/MediaWiki:Main.js?action=raw&ctype=text/javascript", "text/javascript");
 |  | 
|  | }
 |  | 
|  | }catch(e) { console.log("Error, MediaWiki:Main.js 加载失败");console.error(e, e.stack);}
 |  | 
|  |   |  | 
|  |   |  | 
|  | try {
 |  | 
|  | 	mw.loader.load("/wukong/MediaWiki:BWikiLocalUser.js?action=raw&ctype=text/javascript", "text/javascript");
 |  | 
|  | }catch(e) { console.log("Error, MediaWiki:BWikiLocalUser.js 加载失败");console.error(e, e.stack);}
 |  | 
|  |   |  | 
|  |   |  | 
|  | // 特性支持:加载 编辑器扩展 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);}
 |  | 
|  |   |  | 
|  | /* 加载 font-awesome */
 |  | 
|  | mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css', 'text/css');
 |  | 
|  |   |  | 
|  |   |  | 
|  | // 特性支持: 快捷编辑理由。支持编辑摘要时,点击快捷选项填充编辑理由
 |  | 
|  | // 参考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') { // 编辑页面
 |  | 
|  |     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 特性支持: 快捷编辑理由 */
 |  | 
|  |   |  | 
|  |   |  | 
|  | // 特性支持: 加载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._is_main_css_loaded = true; |  | 
|  | }
 |  | 
|  | }catch(e) { console.log("MediaWiki:Common.js:Error, MediaWiki:Main.css 加载失败");console.error(e, e.stack);}
 |  | 
|  | /* end 特性支持:加载main.css */
 |  | 
|  |   |  | 
|  |   |  | 
|  | /* 特性支持:参见[[模板:ResourceLoader]]*/
 |  | 
|  | $('.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命名空间,也就是说,只允许加载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();
 |  | 
|  | 	returnmw.loader.load("//wiki.biligame.com/wukong/index.php?title="+text+"&action=raw&ctype=text/javascript", "text/javascript");
 |  | 
|  | });
 |  | 
|  | /* end 特性支持: ResourceLoader */
 |  | 
|  |   |  | 
|  |   |  | 
|  | /* 特性支持:加载字体, 利用indexedDB缓存 */
 |  | 
|  | /*
 |  | 
|  | try {
 |  | 
|  |   function loadFonts() {
 |  | 
|  |     var dbName = "WuKong";
 |  | 
|  |     var objectStoreName = "fonts";
 |  | 
|  |     var dbVersion = 1;
 |  | 
|  |     var db = null;
 |  | 
|  |   |  | 
|  |     function getFontData(key, fontName, weight) {
 |  | 
|  |       var objectStore = db.transaction([objectStoreName], "readonly").objectStore(objectStoreName);
 |  | 
|  |       var getRequest = objectStore.get(key);
 |  | 
|  |   |  | 
|  |       getRequest.onsuccess = function (event) {
 |  | 
|  |         fontData = event.target.result;
 |  | 
|  |         if (fontData) {
 |  | 
|  |           console.log('尝试加载' + fontName + '本地缓存');
 |  | 
|  |           var fontFace = newFontFace(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");
 |  | 
|  |         }
 |  | 
|  |       };
 |  | 
|  |     }
 |  | 
|  |   |  | 
|  |     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");
 |  | 
|  |     };
 |  | 
|  |    } |  |    } | 
|  |   |  |    // 兼容旧格式:2025-04-05 03:00:00 | 
|  |    loadFonts(); |  |   return new Date(dateStr.replace(' ', 'T') + 'Z'); | 
|  | } catch (error) {
 |  | 
|  |   console.error("Error:", error);
 |  | 
|  | }
 |  | 
|  | */
 |  | 
|  |   |  | 
|  | //编辑器插件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!");
 |  | 
|  | });
 |  | 
|  |   |  | 
|  |   |  | 
|  | // https://wiki.biligame.com/umamusume/MediaWiki:Common.js
 |  | 
|  | // 加载ES6模块
 |  | 
|  | function loadModuleES6(src, callback) {
 |  | 
|  | 	var script = document.createElement('script'),
 |  | 
|  | 	head = document.getElementsByTagName('head')[0];
 |  | 
|  | 	script.type = 'module';
 |  | 
|  | 	script.charset = 'UTF-8';
 |  | 
|  | 	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();
 |  | 
|  | 			}
 |  | 
|  | 		});
 |  | 
|  | 	}
 |  | 
|  | 	head.appendChild(script);
 |  | 
|  | } |  | } | 
|  | 
 |  | 
 | 
|  | //加载表情包插件 |  | // 示例使用 | 
|  | // 来自seerplan,源自umamusume
 |  | var startTime = parseDate("{{{start_time|2025-04-05 03:00:00}}}"); | 
|  | $(function(){
 |  | 
|  | 	loadModuleES6("//wiki.biligame.com/wukong/index.php?title=MediaWiki:Emotion.js&action=raw&ctype=text/javascript", function() {
 |  | 
|  | 		console.log("Flowthread Add-on Emotion loaded!");
 |  | 
|  | 	});
 |  | 
|  | }); |  |