MediaWiki:Header.js:修订间差异

MediaWiki系统消息页面
无编辑摘要
无编辑摘要
第1行: 第1行:
// 把整个body都选上,以便下一步使用
var page = document.querySelector("body");
var page = document.querySelector("body");
var url = window.location.href;
if (page.classList.contains('page-首页')) {
// 仅修改 body class 中有 page-首页 的页面
 
if (url = "https://wiki.dollancraft.top/") {
// 找到我们要插入新div之后的element
var mwBody = document.getElementById('content');
var mwBody = document.getElementById('content');
// 新建一个div
var newDiv = document.createElement('div');
var newDiv = document.createElement('div');
// 给新插入的element设个class名
newDiv.setAttribute('class', 'header-img');
newDiv.setAttribute('class', 'header-hero');
newDiv.innerHTML = '<div class="header-img" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 150%), url(mainpage.png);background-size: cover;background-position: center center;height: 36vh;margin-bottom: -31vh;"></div>';
// 加上html内容
newDiv.innerHTML = '<div class="header-hero-image" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 150%), url(mainpage.png);background-size: cover;background-position: center center;height: 36vh;margin-bottom: -31vh;"></div>';


// 将新 div 插入 content 之前
// 将新 div 插入 content 之前
mwBody.parentNode.insertBefore(newDiv, mwBody);
mwBody.parentNode.insertBefore(newDiv, mwBody);
}
}

2023年10月6日 (五) 22:29的版本

var page = document.querySelector("body");
if (page.classList.contains('page-首页'))  {
	var mwBody = document.getElementById('content');
	var newDiv = document.createElement('div');
	newDiv.setAttribute('class', 'header-img');
	newDiv.innerHTML = '<div class="header-img" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 150%), url(mainpage.png);background-size: cover;background-position: center center;height: 36vh;margin-bottom: -31vh;"></div>';

	// 将新 div 插入 content 之前
	mwBody.parentNode.insertBefore(newDiv, mwBody);
}