b站网页精简
(function() {
'use strict';
const hideElements = (selectors) => {
selectors.forEach(selector => {
const elements = document.querySelectorAll(selector);
elements.forEach(el => {
el.style.display = 'none';
});
});
};
const modifyVideoPage = () => {
const videoPageSelectors = [
'.header-channel',
'.bili-header__channel',
'.bili-header__banner',
'.adblock-tips',
'.palette-button-wrap'
];
hideElements(videoPageSelectors);
const videoPodBody = document.querySelector('.video-pod__body');
if (videoPodBody) {
videoPodBody.style.height = '500px';
videoPodBody.style.maxHeight = '500px';
}
const rcmdTab = document.querySelector('.rcmd-tab');
if (rcmdTab) {
rcmdTab.style.height = '500px';
}
const videoPod = document.querySelector('.video-pod.video-pod');
if (videoPod) {
videoPod.style.height = '500px';
}
};
const simplifyHomePage = () => {
const homePageSelectors = [
'.header-channel',
'.bili-header__channel',
'.bili-header__banner',
'.adblock-tips',
'.palette-button-wrap',
'.left-entry',
'main.bili-feed4-layout'
];
hideElements(homePageSelectors);
const centerSearchContainer = document.querySelector('.center-search-container');
if (centerSearchContainer) {
centerSearchContainer.style.position = 'absolute';
centerSearchContainer.style.left = '50%';
centerSearchContainer.style.transform = 'translateX(-50%)';
centerSearchContainer.style.marginTop = '40vh';
}
const rightEntry = document.querySelector('.right-entry');
if (rightEntry) {
rightEntry.style.position = 'absolute';
rightEntry.style.left = '50%';
rightEntry.style.transform = 'translateX(-50%)';
rightEntry.style.marginTop = '70vh';
}
};
const modifyGlobalStyles = () => {
const biliHeader = document.querySelector('.bili-header.large-header');
if (biliHeader) {
biliHeader.style.backgroundColor = '#121212';
}
const grayElements = document.querySelectorAll('.gray');
grayElements.forEach(el => {
el.style.backgroundColor = '#121212';
});
};
const observeDynamicElements = () => {
const observer = new MutationObserver(() => {
if (window.location.pathname.startsWith('/video/')) {
modifyVideoPage();
} else if (window.location.pathname === '/') {
simplifyHomePage();
}
});
observer.observe(document.body, { childList: true, subtree: true });
};
if (window.location.pathname.startsWith('/video/')) {
modifyVideoPage();
} else if (window.location.pathname === '/') {
simplifyHomePage();
}
modifyGlobalStyles();
observeDynamicElements();
})();