|
|
(未显示同一用户的15个中间版本) |
第1行: |
第1行: |
| /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ | | // 引入jQuery计时器插件[6](@ref) |
| function getCookie(name) {
| | mw.loader.load('//cdn.jsdelivr.net/npm/jquery-countdown@2.2.0/dist/jquery.countdown.min.js'); |
| var value = '; ' + document.cookie;
| |
| var parts = value.split('; ' + name + '=');
| |
| if (parts.length === 2) return parts.pop().split(';').shift();
| |
| }
| |
| | |
| | |
| // 特性支持:加载 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();
| |
| return mw.loader.load("//wiki.biligame.com/wukong/index.php?title="+text+"&action=raw&ctype=text/javascript", "text/javascript");
| |
| });
| |
| /* end 特性支持: ResourceLoader */
| |
|
| |
|
| | // 维护开始时间戳(2025-04-05 03:00:00 UTC) |
| | // 维护开始时间(示例:2020-09-01 00:00:00 UTC) |
| | const startTimestamp = 1743793200; |
|
| |
|
| /* 特性支持:加载字体, 利用indexedDB缓存 */
| | function updateMaintenanceTimer() { |
| /*
| | const now = Math.floor(Date.now() / 1000); // 当前时间戳(秒) |
| try {
| | const duration = now - startTimestamp; |
| 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);
| | const days = Math.floor(duration / 86400); |
| var getRequest = objectStore.get(key);
| | const hours = Math.floor((duration % 86400) / 3600); |
| | const minutes = Math.floor((duration % 3600) / 60); |
| | const seconds = duration % 60; |
|
| |
|
| getRequest.onsuccess = function (event) {
| | // 更新页面显示 |
| fontData = event.target.result;
| | const timerElement = document.getElementById("maintenance-timer"); |
| if (fontData) {
| | if (timerElement) { |
| console.log('尝试加载' + fontName + '本地缓存');
| | timerElement.textContent =`距离本赛季已维护${days}天${hours}时${minutes}分${seconds}秒`; |
| 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");
| |
| }
| |
| };
| |
| } | | } |
|
| |
| 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");
| |
| };
| |
| }
| |
|
| |
| loadFonts();
| |
| } 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
| | updateMaintenanceTimer(); |
| $(function(){
| | // 每秒刷新 |
| loadModuleES6("//wiki.biligame.com/wukong/index.php?title=MediaWiki:Emotion.js&action=raw&ctype=text/javascript", function() {
| | setInterval(updateMaintenanceTimer, 1000); |
| console.log("Flowthread Add-on Emotion loaded!");
| |
| });
| |
| });
| |