MediaWiki:Common.js
MediaWiki界面页面
更多操作
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
if (mw.config.get('wgPageName') === '首页') {
var event = new KeyboardEvent('keydown', {
key: '/',
keyCode: 65,
which: 65,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false
});
var skin_search = document.getElementById('skin-citizen-search-trigger');
// 添加点击事件监听器
skin_search.addEventListener('click', function() {
document.dispatchEvent(event); //执行
});
$(function() {
/* 头图 */
var mwBody = document.getElementById('content');
var newDiv = document.createElement('div');
newDiv.setAttribute('class', 'header-image');
newDiv.innerHTML = '<div class="header-image" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 50%), url(https://galbaike.com/images/2/26/%E9%A6%96%E9%A1%B5%E5%A4%B4%E5%9B%BE3.png);background-size: cover;background-position: top;height: 36vh;margin-bottom: -37vh;"></div>';
mwBody.parentNode.insertBefore(newDiv, mwBody);
}())
}
if ($('.bvideo').length > 0) {
var dataIdValue = $('.bvideo').data('id');
console.log('目标<div>存在,可以执行相关操作'+dataIdValue );
}
$('.bvideo').each(function() {
var dataIdValue = $(this).data('id');
var iframeElement = $('<iframe>', {
src: 'https://player.bilibili.com/player.html?bvid='+dataIdValue ,
width: '100%',
height: '360',
frameborder: '0',
allowfullscreen: 'allowfullscreen'
});
$(this).append(iframeElement);
console.log('目标<div>存在,可以执行相关操作'+dataIdValue );
});
$(document).ready(function(){
$(".jskpjs").click(function(){
$(this).find('.jskp-card').toggleClass('jskp-flipped');
});
});
mw.loader.load('https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-confirm/3.3.4/jquery-confirm.min.js');
var img_index = 0;
var img_array = [];
$(".jskp_js").on("click", function(){
var kp_img = $(this).data('id');//用这个传递图片的
var kp_img = kp_img.split(";");//处理;的分隔
img_array = kp_img;
var dataNameValue = $(this).data('name');
var dataYmValue = $(this).data('ym');
var jsDiv = $(this).find('#div1').html();
var jsDiv2 = $(this).find('#js2').html();
var jsDiv3 = $(this).find('#js3').html();
var boxHeight = $(window).height() * 0.7;
$.alert({
//title:'角色详情',
title: '<div style="margin: 5px;"><h4 style="margin: 0;"><span>'+dataNameValue+'</span></h4><div style="font-size: 1rem;font-style: italic;">'+dataYmValue +'</div><div>',
closeIcon: true,
content: '<div style="max-height:'+boxHeight+'px;" >'+
'<div style="display: flex;flex-wrap:wrap;">'+
'<div style="padding: 5px;width: 30%;overflow: hidden;">' +
'<img id="lihui" src="'+ kp_img[0] +'" style="width: 100%;height: auto;aspect-ratio: 9 / 16;object-fit: cover;object-position: top;box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;border-radius: 20px;">' +
'</div>' +
'<div style="margin: 10px;width: calc(66% - 20px);">' +
'<div style="margin-top: -10px;">'+jsDiv+'<a onclick="kp2_img(event)">切换立绘</a></div>'+
'</div>' +
'<!--div style="max-height: 300px;margin: 10px;width:100%">' +
'<div style="margin-top: 10px;">'+jsDiv+jsDiv2+'</div>'+
'</div>' +
'</div--></div>',
});
if(kp_img[1] === undefined || kp_img[1] === null){
console.log(kp_img);
console.log('只有一个立绘!');
}else{
console.log(kp_img);
var xxcss = document.querySelector(".xxcss");
xxcss.innerHTML += '<a onclick="kp2_img(event)">切换立绘</a></div>';
img_index = 0;
}
});
function kp2_img(event){
img_index = (img_index + 1) % img_array.length;
var parentElement = event.target.parentNode.parentNode.parentNode.parentNode;
var imageElement = parentElement.querySelector("#lihui");
imageElement.src = img_array[img_index ];
}