MediaWiki:Common.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。
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ // 检查当前页面的标题或 URL 是否符合条件 if (mw.config.get('wgCanonicalSpecialPageName') === 'User:Selfice/sandbox/首页') { // 替换为你想限制的页面名称或条件 // 等待 DOM 完全加载 document.addEventListener("DOMContentLoaded", function() { // 获取父元素和两个子元素 const parentElement = document.querySelector('.grid_block'); const firstChild = parentElement.children[0]; const secondChild = parentElement.children[1]; // 获取第一个子元素的高度 const firstChildHeight = firstChild.offsetHeight; // 将第一个子元素的高度应用到第二个子元素的 max-height 上 secondChild.style.maxHeight = firstChildHeight + 'px'; }); }