up
This commit is contained in:
parent
703252c2e4
commit
cec609debc
184
MCdoc.js
Normal file
184
MCdoc.js
Normal file
@ -0,0 +1,184 @@
|
||||
// ==UserScript==
|
||||
// @name 中国版我的世界开发者文档 美化
|
||||
// @namespace https://git.xjyofc.top/xjy/MCdoc_js
|
||||
// @version 1.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+x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F3kGdFYXd7Sj03mgP84qIIzBnF49kDCdXCyOCxgTRtiMXy+SrgaYa+UyDzWCrf8KYM0JSo1+Q/6V80ARgx4F0/r+JYfeheqSi3OxD5bCH6HkGytBQCWRInrRrkVQz1HxpELlvSh/B1eMmwVAKlVVqlVVq2G7L+BeQNK4xbulIXAAAAAElFTkSuQmCC
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// 隐藏NIE-topBar元素
|
||||
document.getElementById('NIE-topBar').style.display = 'none';
|
||||
|
||||
// 将nav-bar元素置顶
|
||||
const navBar = document.querySelector('.nav-bar');
|
||||
if (navBar) {
|
||||
navBar.style.top = '0';
|
||||
}
|
||||
|
||||
// 将header.navbar.fixed-navbar元素置顶
|
||||
const header = document.querySelector('header.navbar.fixed-navbar');
|
||||
if (header) {
|
||||
header.style.top = '0';
|
||||
}
|
||||
|
||||
// 设置.search-btn的宽度为65px
|
||||
const searchBtn = document.querySelector('.search-btn');
|
||||
if (searchBtn) {
|
||||
searchBtn.style.width = '60px';
|
||||
}
|
||||
|
||||
// 设置.search-box宽度为auto
|
||||
const searchBox = document.querySelector('.search-box');
|
||||
if (searchBox) {
|
||||
searchBox.style.width = 'auto';
|
||||
}
|
||||
|
||||
// 设置.search-cont宽度为auto并移动到navbar fixed-navbar中置顶居中
|
||||
const searchCont = document.querySelector('.search-cont');
|
||||
const newheader = document.querySelector('header.navbar.fixed-navbar');
|
||||
if (searchCont && newheader) {
|
||||
searchCont.style.width = 'auto';
|
||||
searchCont.style.position = 'fixed';
|
||||
searchCont.style.top = '22px';
|
||||
searchCont.style.left = '50%';
|
||||
searchCont.style.transform = 'translateX(-90%)';
|
||||
header.appendChild(searchCont);
|
||||
}
|
||||
|
||||
// 隐藏.page-top元素
|
||||
// 动态隐藏.page-top元素
|
||||
function hidePageTop() {
|
||||
const pageTop = document.querySelector('.page-top');
|
||||
const pageTopFixed = document.querySelector('.page-top-fixed');
|
||||
const pageTopboth = document.querySelector('.page-top-fixed.page-top');
|
||||
if (pageTop) {
|
||||
pageTop.style.display = 'none';
|
||||
}
|
||||
if (pageTopFixed) {
|
||||
pageTopFixed.style.display = 'none';
|
||||
}
|
||||
if (pageTopboth) {
|
||||
pageTopboth.style.display = 'none';
|
||||
}
|
||||
// 移除.page元素的padding-top
|
||||
const page = document.querySelector('.page');
|
||||
if (page) {
|
||||
page.style.paddingTop = '0';
|
||||
}
|
||||
}
|
||||
|
||||
// 初始隐藏
|
||||
hidePageTop();
|
||||
|
||||
// 监听DOM变化和页面重新渲染
|
||||
const observer = new MutationObserver(function(mutations) {
|
||||
hidePageTop();
|
||||
// 检查是否有节点被添加或属性变化
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.addedNodes.length > 0 || mutation.attributeName) {
|
||||
console.log('检测到页面重新渲染');
|
||||
// 在这里添加重新渲染后的处理逻辑
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['style', 'class']
|
||||
});
|
||||
|
||||
// 监听窗口缩放事件
|
||||
window.addEventListener('resize', hidePageTop);
|
||||
// 监听滚动事件
|
||||
window.addEventListener('scroll', hidePageTop);
|
||||
|
||||
// 隐藏.nav-btn元素
|
||||
const navBtn = document.querySelector('.nav-btn');
|
||||
if (navBtn) {
|
||||
navBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
// 设置.center-cont宽度为auto
|
||||
const centerCont = document.querySelector('.center-cont');
|
||||
if (centerCont) {
|
||||
centerCont.style.width = 'auto';
|
||||
}
|
||||
|
||||
// 隐藏.btn-cont元素
|
||||
const btnCont = document.querySelector('.btn-cont');
|
||||
if (btnCont) {
|
||||
btnCont.style.display = 'none';
|
||||
}
|
||||
|
||||
// 隐藏.open-right元素
|
||||
const openRight = document.querySelector('.open-right');
|
||||
if (openRight) {
|
||||
openRight.style.display = 'none';
|
||||
}
|
||||
|
||||
// 设置.sidebar元素的top样式
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
if (sidebar) {
|
||||
sidebar.style.top = '75px';
|
||||
sidebar.style.height = '-webkit-fill-available';
|
||||
sidebar.style.removeProperty('display');
|
||||
}
|
||||
|
||||
// 创建urlmenu菜单
|
||||
const urlMenu = document.createElement('div');
|
||||
urlMenu.className = 'urlmenu';
|
||||
urlMenu.innerHTML = `
|
||||
<a href="https://mc.163.com/dev/apidocs.html">API文档</a>
|
||||
<a href="https://mc.163.com/dev/guide.html">开发指南</a>
|
||||
<a href="https://mc.163.com/dev/course.html">教学课程</a>
|
||||
<a href="https://mc.163.com/dev/newslist.html">新闻与活动</a>
|
||||
<a href="https://mc.163.com/dev/help.html">帮助中心</a>
|
||||
<a href="https://mcdev.webapp.163.com/#/feedbackModal?target=browser" target="_blank">问题反馈</a>
|
||||
<a href="https://adl.netease.com/d/g/mc/c/dev">MCStudio</a>
|
||||
`;
|
||||
|
||||
// 设置菜单样式
|
||||
urlMenu.style.position = 'fixed';
|
||||
urlMenu.style.right = '20px';
|
||||
urlMenu.style.top = '15px';
|
||||
// urlMenu.style.backgroundColor = 'rgba(0, 0, 0, 0)';
|
||||
urlMenu.style.padding = '10px';
|
||||
urlMenu.style.borderRadius = '5px';
|
||||
|
||||
// 添加到navbar fixed-navbar中
|
||||
if (header) {
|
||||
header.appendChild(urlMenu);
|
||||
}
|
||||
|
||||
// 为.theme-default-content添加圆角
|
||||
const themeContent = document.querySelector('.theme-default-content');
|
||||
if (themeContent) {
|
||||
themeContent.style.borderRadius = '8px';
|
||||
}
|
||||
|
||||
// 隐藏footer元素
|
||||
const footer = document.querySelector('.footer');
|
||||
if (footer) {
|
||||
footer.style.display = 'none';
|
||||
}
|
||||
|
||||
// 隐藏反馈按钮
|
||||
const feedbackBtn = document.querySelector('.btn.feedback');
|
||||
if (feedbackBtn) {
|
||||
feedbackBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
// 隐藏.hide-side元素
|
||||
const hideSide = document.querySelector('.hide-side');
|
||||
if (hideSide) {
|
||||
hideSide.style.display = 'none';
|
||||
}
|
||||
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user