本WIKI编辑权限开放,欢迎大家共同建设
也可以 收藏本WIKI 防止迷路
编辑帮助:目录
目前Wiki编辑组急缺美术,希望有能力、有意向的老师可以参与一起建设本站
全站通知:
MediaWiki:Main.js
刷
历
编
跳到导航
跳到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
console.log("MediaWiki:Main.js update 加载成功");
Img_UrlLoad();
setFavicon(); // 动态修改网站图标
window.onload = function () {
console.log("MediaWiki:Main.js 页面加载完成时执行");
Img_UrlLoad();
Img_ClickAmplification();
setFavicon(); // 动态修改网站图标
};
function Img_UrlLoad() {
document.querySelectorAll('.exter-img').forEach(function (getImgGroup) {
const getImg = getImgGroup.querySelector('.imgurl');
if (!getImg) return;
const frameid = `frameimg${Math.random()}`;
if (!window.img) window.img = {}; // 初始化全局存储对象
window.img[frameid] = `
<style>body { margin: 0; overflow: hidden;}</style>
<img id="img" src="${getImg.getAttribute('data-url')}" style="width:100%" />
<script>window.onload = function() {
parent.document.getElementById("${frameid}").height = document.getElementById("img").height + "px";
};</script>
`;
const iFrame = document.createElement('iframe');
iFrame.id = frameid;
iFrame.src = `javascript:parent.img['${frameid}'];`; // 动态生成iframe内容
iFrame.style.width = '100%';
iFrame.style.border = '0';
getImg.parentNode.replaceChild(iFrame, getImg);
const exterImgPointer = getImgGroup.querySelector('.exter-img-pointer'); // 新增:查找exter-img-pointer元素
if (!exterImgPointer || !exterImgPointer.hasAttribute('data-show')) return;
exterImgPointer.addEventListener('click', function () {
const containerDiv = document.createElement('div');
const fs_Img = document.createElement('img');
fs_Img.src = exterImgPointer.getAttribute('data-show');
containerDiv.classList.add('exter-show');
containerDiv.appendChild(fs_Img);
containerDiv.addEventListener('click', () => containerDiv.remove());
document.body.appendChild(containerDiv);
console.log("创建图片");
});
});
}
function Img_ClickAmplification() {
// 为所有.showOn元素添加点击事件监听器,用于显示放大图片
document.querySelectorAll('.showOn').forEach(element => {
element.addEventListener('click', function () {
// 获取当前元素的下一个兄弟元素
const nextElement = this.nextElementSibling;
// 检查是否存在且是否为.showOnImg类
if (nextElement && nextElement.classList.contains('showOnImg')) {
// 克隆需要显示的元素
const clone = nextElement.cloneNode(true);
// 将克隆添加到页面body
document.body.appendChild(clone);
// 设置克隆元素的可见性和透明度
clone.style.visibility = 'visible';
clone.style.opacity = '1';
// 绑定点击事件,点击后移除自身
clone.addEventListener('click', () => clone.remove());
}
});
});
}
function setFavicon() {
//更换网页icon
try {
$("link[rel='shortcut icon']").attr("href",
"https://patchwiki.biligame.com/images/intothevoid/2/26/7ohyblafvyx68f5b78r7nkrswpgltk3.png");
} catch (err) {
console.log('设置 favicon 出错');
}
}