// ==UserScript==
// @name 中国版我的世界开发者文档 美化
// @namespace https://git.xjyofc.top/xjy/MCdoc_js
// @updateURL https://git.xjyofc.top/xjy/MCdoc_js/raw/branch/main/MCdoc.user.js
// @downloadURL https://git.xjyofc.top/xjy/MCdoc_js/raw/branch/main/MCdoc.user.js
// @version 2.0
// @description 更好的中国版我的世界开发者文档界面
// @author 仙君御
// @match https://mc.163.com/dev/*
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFyklEQVR4nO1ZfWhbVRTPhooKgiCoA2F+NB/rPpr7XpJ732uS1yZNm6RLme3SrN3ark1r122tmyuxG6tzH+36seLm/EsmqNtUVJyi6NTCXAf6lwiiKCiiwz/Uf9w/TpmzV85rk7y8vHfva+sGQi78IHk595zze+fcc857sdlKq7RKq7T+F8uOyFGHQCgf+C+721fB0+cQ8HeW9CFyZWWFcveSCbi85AdrBFR8/QAhd5jpKvd671+ALuoQ8dDSnPdIa0DR2kqJjn8Sp5OXjNH7TFgbiWfN9DlFKQkymTN1proA8Z5gVtevrBvCXQ4RD4Oi+l6FaTCazhpUMVuGSMJQHyInXJhcm7horgsg1Mg5fXZEdi6agMuDvwQl25+rMTUGkYEI6c7Dby5RXFFMAH+upPxXWc4ffC+qPwuXy8vLb1uw884K/OCC8lUHu4A/UBTlFqeHXGHJoZBcQABuloGurQsm4ED4Cdhc0xZghlsLX6xSZ5icViN40jiCe16qpcGN/oJrTXuqigkg/I3NZlu+MAIi+RQ2d0+ELTn/9Lu60M/D5SX0yEcxwz2t+6tpaqi64Fqg0W+ox+n2bbTs/EMY3weH0emR6KH3o5YIAFEjw9WbCu+wFkoqQB8/Fcl9H7sQp6t8pn3mC5vNtszi3cd9sCmYtJ4+0e6CSpRD++GQofzYhThdLUl0dDpWkFKc5ha1RkDAH8OGtkPGxvWYuBij64L6SnQDgMgM13lo3w6RXIMNw2+xG85/jdqtxlHUpNHPXAJ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qIIzBnF49kDCdXCyOCxgTRtiMXy+SrgaYa+UyDzWCrf8KYM0JSo1+Q/6V80ARgx4F0/r+JYfeheqSi3OxD5bCH6HkGytBQCWRInrRrkVQz1HxpELlvSh/B1eMmwVAKlVVqlVVq2G7L+BeQNK4xbulIXAAAAAElFTkSuQmCC
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 新样式
function newUI(){
const navBar = document.querySelector('.nav-bar');
const header = document.querySelector('header.navbar.fixed-navbar');
const searchBtn = document.querySelector('.search-btn');
const searchBox = document.querySelector('.search-box');
const searchCont = document.querySelector('.search-cont');
const themeContent = document.querySelector('.theme-default-content');
const sidebar = document.querySelector('.sidebar');
const page = document.querySelector('.page');
if (navBar) {navBar.style.top = '0';}
if (header) {header.style.top = '0';}
if (searchBtn) { searchBtn.style.width = '60px';}
if (searchBox) {searchBox.style.width = 'auto';}
if (themeContent) { themeContent.style.borderRadius = '8px'; }
if (searchCont && header) {
searchCont.style.width = 'auto';
searchCont.style.position = 'fixed';
searchCont.style.top = '22px';
searchCont.style.left = '50%';
searchCont.style.transform = 'translateX(-90%)';
header.appendChild(searchCont);
}
if (sidebar) {
sidebar.style.top = '75px';
sidebar.style.height = '-webkit-fill-available';
sidebar.style.removeProperty('display');
}
if (page) {
page.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.1)';
page.style.borderRadius = '8px';
}
}
// 动态隐藏元素
function hide() {
const pageTop = document.querySelector('.page-top');
const pageTopFixed = document.querySelector('.page-top-fixed');
const pageTopboth = document.querySelector('.page-top-fixed.page-top');
const navBtn = document.querySelector('.nav-btn');
const btnCont = document.querySelector('.btn-cont');
const openRight = document.querySelector('.open-right');
const page = document.querySelector('.page');
const footer = document.querySelector('.footer');
const feedbackBtn = document.querySelector('.btn.feedback');
const hideSide = document.querySelector('.hide-side');
const nietopbar = document.getElementById('NIE-topBar');
if (pageTop) { pageTop.style.display = 'none'; }
if (pageTopFixed) {pageTopFixed.style.display = 'none';}
if (pageTopboth) {pageTopboth.style.display = 'none';}
if (page) {page.style.paddingTop = '0';}
if (navBtn) {navBtn.style.display = 'none';}
if (btnCont) {btnCont.style.display = 'none';}
if (openRight) {openRight.style.display = 'none';}
if (footer) {footer.style.display = 'none';}
if (feedbackBtn) {feedbackBtn.style.display = 'none';}
if (hideSide) { hideSide.style.display = 'none';}
if (nietopbar) {nietopbar.style.display = 'none';}
}
// 页面布局修复
function fix() {
const page = document.querySelector('.page');
if (page) {
page.style.paddingTop = '0';
page.style.flex = '0';
page.style.marginLeft = 'auto';
page.style.width = '67%';
page.style.overflow = 'visible';
}
const pageContent = document.querySelector('.page-container');
if (pageContent) {
pageContent.style.display = 'block';
}
// 设置html宽度为浏览器窗口实际大小
const htmlElement = document.documentElement;
if (htmlElement) {
htmlElement.style.width = window.innerWidth + 'px';
htmlElement.style.minWidth = window.innerWidth + 'px';
htmlElement.style.transform = 'none';
// 确保不出现横向滚动条
htmlElement.style.overflowX = 'hidden';
}
// 设置body元素宽度
if (document.body) {
document.body.style.width = window.innerWidth + 'px';
}
// 设置id为app的元素宽度
const appElement = document.getElementById('app');
if (appElement) {
appElement.style.width = window.innerWidth + 'px';
}
}
// 创建urlmenu菜单
function Menu() {
const header = document.querySelector('header.navbar.fixed-navbar');
const urlMenu = document.createElement('div');
urlMenu.className = 'urlmenu';
urlMenu.innerHTML = `
API文档
开发指南
教学课程
新闻与活动
帮助中心
问题反馈
MCStudio
`;
// 设置菜单样式
urlMenu.style.position = 'fixed';
urlMenu.style.right = '20px';
urlMenu.style.top = '15px';
urlMenu.style.padding = '10px';
urlMenu.style.borderRadius = '5px';
// urlMenu.style.backgroundColor = 'rgba(0, 0, 0, 0)';
// 添加到navbar fixed-navbar中
if (header) {header.appendChild(urlMenu);}
}
// 注册功能函数
function mian() {
hide();
Menu();
newUI();
fix();
}
// 监听在页面和脚本渲染完成后
document.addEventListener('DOMContentLoaded', function() {
mian();
});
// 监听窗口大小变化
window.addEventListener('resize', function() {
mian();
})
// 监听页面滚动事件
window.addEventListener('scroll', function() {
mian();
});
// 监听文档加载状态变化(开始渲染时)
document.addEventListener('readystatechange', function() {
// interactive表示DOM已加载但资源可能未完成,complete表示所有资源加载完成
if (document.readyState === 'interactive' || document.readyState === 'complete') {
mian();
}
});
})();